From d0be2f5840fcadb6f2852bbf2c35082760165388 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 8 Feb 2019 10:48:49 -0600 Subject: CMake script changes to simplify execution --- MANIFEST | 7 +- config/cmake/scripts/HDF5config.cmake | 147 +++++++++++---------- config/cmake/scripts/HPC/bsub-HDF5options.cmake | 49 +++++++ config/cmake/scripts/HPC/par-HDF5options.cmake | 126 ------------------ config/cmake/scripts/HPC/raybsub-HDF5options.cmake | 49 +++++++ config/cmake/scripts/HPC/sbatch-HDF5options.cmake | 49 +++++++ config/cmake/scripts/HPC/ser-HDF5options.cmake | 119 ----------------- 7 files changed, 231 insertions(+), 315 deletions(-) create mode 100644 config/cmake/scripts/HPC/bsub-HDF5options.cmake delete mode 100644 config/cmake/scripts/HPC/par-HDF5options.cmake create mode 100644 config/cmake/scripts/HPC/raybsub-HDF5options.cmake create mode 100644 config/cmake/scripts/HPC/sbatch-HDF5options.cmake delete mode 100644 config/cmake/scripts/HPC/ser-HDF5options.cmake diff --git a/MANIFEST b/MANIFEST index 5af06ac..2b48295 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3369,8 +3369,11 @@ ./config/cmake/scripts/CTestScript.cmake ./config/cmake/scripts/HDF5config.cmake ./config/cmake/scripts/HDF5options.cmake -./config/cmake/scripts/HPC/par-HDF5options.cmake -./config/cmake/scripts/HPC/ser-HDF5options.cmake + +# CMake-specific HPC Scripts +./config/cmake/scripts/HPC/sbatch-HDF5options.cmake +./config/cmake/scripts/HPC/bsub-HDF5options.cmake +./config/cmake/scripts/HPC/raybsub-HDF5options.cmake # Files generated by autogen ./aclocal.m4 diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index 1d8d501..fda9fcc 100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -44,6 +44,8 @@ set (CTEST_SOURCE_VERSEXT "") #CTEST_CONFIGURATION_TYPE - Release, Debug, RelWithDebInfo #CTEST_SOURCE_NAME - name of source folder; HDF5-1.10.0 #MODEL - CDash group name +#HPC - run alternate configurations for HPC machines; sbatch, bsub, raybsub +#MPI - enable MPI; if (DEFINED CTEST_SCRIPT_ARG) # transform ctest script arguments of the form # script.ctest,var1=value1,var2=value2 @@ -56,6 +58,11 @@ if (DEFINED CTEST_SCRIPT_ARG) endforeach () endif () +#HPC - run alternate configurations for HPC machines +if (DEFINED HPC) + set (BUILD_GENERATOR "Unix") +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") @@ -93,77 +100,81 @@ endif () ################################################################### ######### Following describes compiler ############ -if (WIN32) - set (SITE_OS_NAME "Windows") - set (SITE_OS_VERSION "WIN7") - if (${BUILD_GENERATOR} STREQUAL "VS201764") - set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2017") - set (SITE_COMPILER_VERSION "15") - elseif (${BUILD_GENERATOR} STREQUAL "VS2017") - set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2017") - set (SITE_COMPILER_VERSION "15") - elseif (${BUILD_GENERATOR} STREQUAL "VS201564") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2015") - set (SITE_COMPILER_VERSION "14") - elseif (${BUILD_GENERATOR} STREQUAL "VS2015") - set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2015") - set (SITE_COMPILER_VERSION "14") - elseif (${BUILD_GENERATOR} STREQUAL "VS201364") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2013") - set (SITE_COMPILER_VERSION "12") - elseif (${BUILD_GENERATOR} STREQUAL "VS2013") - set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2013") - set (SITE_COMPILER_VERSION "12") - elseif (${BUILD_GENERATOR} STREQUAL "VS201264") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") - set (SITE_OS_BITS "64") - set (SITE_COMPILER_NAME "vs2012") - set (SITE_COMPILER_VERSION "11") - elseif (${BUILD_GENERATOR} STREQUAL "VS2012") - set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") - set (SITE_OS_BITS "32") - set (SITE_COMPILER_NAME "vs2012") - set (SITE_COMPILER_VERSION "11") +if (NOT DEFINED HPC) + if (WIN32) + set (SITE_OS_NAME "Windows") + set (SITE_OS_VERSION "WIN7") + if (${BUILD_GENERATOR} STREQUAL "VS201764") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS2017") + set (CTEST_CMAKE_GENERATOR "Visual Studio 15 2017") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2017") + set (SITE_COMPILER_VERSION "15") + elseif (${BUILD_GENERATOR} STREQUAL "VS201564") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS2015") + set (CTEST_CMAKE_GENERATOR "Visual Studio 14 2015") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2015") + set (SITE_COMPILER_VERSION "14") + elseif (${BUILD_GENERATOR} STREQUAL "VS201364") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS2013") + set (CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") + set (SITE_OS_BITS "32") + set (SITE_COMPILER_NAME "vs2013") + set (SITE_COMPILER_VERSION "12") + elseif (${BUILD_GENERATOR} STREQUAL "VS201264") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") + set (SITE_OS_BITS "64") + set (SITE_COMPILER_NAME "vs2012") + set (SITE_COMPILER_VERSION "11") + elseif (${BUILD_GENERATOR} STREQUAL "VS2012") + set (CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") + set (SITE_OS_BITS "32") + 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") + endif () + ## Set the following to unique id your computer ## + set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") else () - message (FATAL_ERROR "Invalid BUILD_GENERATOR must be - Unix, VS2017, or VS201764, VS2015, VS201564, VS2013, VS201364") + set (CTEST_CMAKE_GENERATOR "Unix Makefiles") + ## Set the following to unique id your computer ## + if (APPLE) + set (CTEST_SITE "MAC.XXXX") + else () + set (CTEST_SITE "LINUX.XXXX") + endif () + if (APPLE) + execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set (ENV{CC} "${XCODE_CC}") + set (ENV{CXX} "${XCODE_CXX}") + set (CTEST_USE_LAUNCHERS 1) + set (RR_WARNINGS_COMMON "-Wno-format-nonliteral -Wno-cast-align -Wno-unused -Wno-unused-variable -Wno-unused-function -Wno-self-assign -Wno-unused-parameter -Wno-sign-compare") + set (RR_WARNINGS_C "${RR_WARNINGS_COMMON} -Wno-deprecated-declarations -Wno-uninitialized") + set (RR_WARNINGS_CXX "${RR_WARNINGS_COMMON} -Woverloaded-virtual -Wshadow -Wwrite-strings -Wc++11-compat") + set (RR_FLAGS_COMMON "-g -O0 -fstack-protector-all -D_FORTIFY_SOURCE=2") + set (RR_FLAGS_C "${RR_FLAGS_COMMON}") + set (RR_FLAGS_CXX "${RR_FLAGS_COMMON}") + set (ENV{CFLAGS} "${RR_WARNINGS_C} ${RR_FLAGS_C}") + set (ENV{CXXFLAGS} "${RR_WARNINGS_CXX} ${RR_FLAGS_CXX}") + endif () endif () -## Set the following to unique id your computer ## - set (CTEST_SITE "WIN7${BUILD_GENERATOR}.XXXX") else () - set (CTEST_CMAKE_GENERATOR "Unix Makefiles") -## Set the following to unique id your computer ## - if (APPLE) - set (CTEST_SITE "MAC.XXXX") - else () - set (CTEST_SITE "LINUX.XXXX") - endif () - if (APPLE) - execute_process (COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process (COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) - set (ENV{CC} "${XCODE_CC}") - set (ENV{CXX} "${XCODE_CXX}") - set (CTEST_USE_LAUNCHERS 1) - set (RR_WARNINGS_COMMON "-Wno-format-nonliteral -Wno-cast-align -Wno-unused -Wno-unused-variable -Wno-unused-function -Wno-self-assign -Wno-unused-parameter -Wno-sign-compare") - set (RR_WARNINGS_C "${RR_WARNINGS_COMMON} -Wno-deprecated-declarations -Wno-uninitialized") - set (RR_WARNINGS_CXX "${RR_WARNINGS_COMMON} -Woverloaded-virtual -Wshadow -Wwrite-strings -Wc++11-compat") - set (RR_FLAGS_COMMON "-g -O0 -fstack-protector-all -D_FORTIFY_SOURCE=2") - set (RR_FLAGS_C "${RR_FLAGS_COMMON}") - set (RR_FLAGS_CXX "${RR_FLAGS_COMMON}") - set (ENV{CFLAGS} "${RR_WARNINGS_C} ${RR_FLAGS_C}") - set (ENV{CXXFLAGS} "${RR_WARNINGS_CXX} ${RR_FLAGS_CXX}") - endif () + include (${CTEST_SOURCE_DIRECTORY}/config/cmake/scripts/HPC/${HPC}-HDF5options.cmake) endif () ################################################################### diff --git a/config/cmake/scripts/HPC/bsub-HDF5options.cmake b/config/cmake/scripts/HPC/bsub-HDF5options.cmake new file mode 100644 index 0000000..5316f41 --- /dev/null +++ b/config/cmake/scripts/HPC/bsub-HDF5options.cmake @@ -0,0 +1,49 @@ +# +# 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. +# +############################################################################################# +#### Change default configuration of options in config/cmake/cacheinit.cmake file ### +#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### +############################################################################################# + +### uncomment/comment and change the following lines for other configuration options + +############################################################################################# +### enable parallel builds +if (DEFINED MPI) + # maximum parallel processor count for build and test #### + set (MAX_PROC_COUNT 8) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=OFF") +endif () +############################################################################################# +### options to run test scripts in batch commands +set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") +set (LOCAL_BATCH_TEST "TRUE") +set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") +set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") + +############################################################################################# +### some additions and alternatives to cross compile on haswell for knl +#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") +#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") +#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") +############################################################################################# diff --git a/config/cmake/scripts/HPC/par-HDF5options.cmake b/config/cmake/scripts/HPC/par-HDF5options.cmake deleted file mode 100644 index c7b22b9..0000000 --- a/config/cmake/scripts/HPC/par-HDF5options.cmake +++ /dev/null @@ -1,126 +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. -# -############################################################################################# -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### -############################################################################################# - -### uncomment/comment and change the following lines for other configuration options - -############################################################################################# -#### maximum parallel processor count for build and test #### -set (MAX_PROC_COUNT 8) - -############################################################################################# -#### alternate toolsets #### -#set (CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler 17.0") - -############################################################################################# -#### Only build static libraries #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") -#### Add PICC option on linux/mac #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") - -############################################################################################# -#### fortran enabled #### -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON") -#### fortran disabled #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") - -############################################################################################# -#### java enabled #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON") -#### java disabled #### -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") - -############################################################################################# -### change install prefix (default use INSTALLDIR value) -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") - -############################################################################################# -#### ext libraries #### - -### ext libs from tgz -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=TGZ -DTGZPATH:PATH=${CTEST_SCRIPT_DIRECTORY}") -### ext libs from git -#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 (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") -#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 -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") -### disable using ext szip -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF") -#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.12.4-Source.tar.gz -DHDF5_EXAMPLES_COMPRESSED_DIR:PATH=${CTEST_SCRIPT_DIRECTORY}") - -############################################################################################# -### enable parallel builds - -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=OFF") - -############################################################################################# -### enable thread-safety builds - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=ON") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_HL_LIB:BOOL=OFF") - -############################################################################################# -### disable test program builds - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=OFF") - -############################################################################################# -### disable packaging - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_NO_PACKAGES:BOOL=ON") -### Create install package with external libraries (szip, zlib) -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") - - -#options to run test scripts in batch commands -set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") -set (LOCAL_BATCH_TEST "TRUE") -set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") -set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") - - -############################################################################################# -### use a toolchain file - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/crayle.cmake") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/intel.cmake") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/GCC.cmake") - -#some additions and alternatives to cross compile on haswell for knl -#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") -#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") -#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") -############################################################################################# diff --git a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake new file mode 100644 index 0000000..5316f41 --- /dev/null +++ b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake @@ -0,0 +1,49 @@ +# +# 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. +# +############################################################################################# +#### Change default configuration of options in config/cmake/cacheinit.cmake file ### +#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### +############################################################################################# + +### uncomment/comment and change the following lines for other configuration options + +############################################################################################# +### enable parallel builds +if (DEFINED MPI) + # maximum parallel processor count for build and test #### + set (MAX_PROC_COUNT 8) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=OFF") +endif () +############################################################################################# +### options to run test scripts in batch commands +set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") +set (LOCAL_BATCH_TEST "TRUE") +set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") +set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") + +############################################################################################# +### some additions and alternatives to cross compile on haswell for knl +#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") +#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") +#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") +############################################################################################# diff --git a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake new file mode 100644 index 0000000..5316f41 --- /dev/null +++ b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake @@ -0,0 +1,49 @@ +# +# 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. +# +############################################################################################# +#### Change default configuration of options in config/cmake/cacheinit.cmake file ### +#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### +############################################################################################# + +### uncomment/comment and change the following lines for other configuration options + +############################################################################################# +### enable parallel builds +if (DEFINED MPI) + # maximum parallel processor count for build and test #### + set (MAX_PROC_COUNT 8) + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=OFF") +endif () +############################################################################################# +### options to run test scripts in batch commands +set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") +set (LOCAL_BATCH_TEST "TRUE") +set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") +set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") + +############################################################################################# +### some additions and alternatives to cross compile on haswell for knl +#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") +#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") +#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") +############################################################################################# diff --git a/config/cmake/scripts/HPC/ser-HDF5options.cmake b/config/cmake/scripts/HPC/ser-HDF5options.cmake deleted file mode 100644 index 7f2e96f..0000000 --- a/config/cmake/scripts/HPC/ser-HDF5options.cmake +++ /dev/null @@ -1,119 +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. -# -############################################################################################# -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### -############################################################################################# - -### uncomment/comment and change the following lines for other configuration options - -############################################################################################# -#### maximum parallel processor count for build and test #### -#set (MAX_PROC_COUNT 8) - -############################################################################################# -#### alternate toolsets #### -#set (CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler 17.0") - -############################################################################################# -#### Only build static libraries #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") -#### Add PICC option on linux/mac #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") - -############################################################################################# -#### fortran enabled #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON") -#### fortran disabled #### -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") - -############################################################################################# -#### java enabled #### -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON") -#### java disabled #### -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") - -############################################################################################# -### change install prefix (default use INSTALLDIR value) -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") - -############################################################################################# -#### ext libraries #### - -### ext libs from tgz -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=TGZ -DTGZPATH:PATH=${CTEST_SCRIPT_DIRECTORY}") -### ext libs from git -#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 (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") -#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 -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") -### disable using ext szip -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF") -#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.12.4-Source.tar.gz -DHDF5_EXAMPLES_COMPRESSED_DIR:PATH=${CTEST_SCRIPT_DIRECTORY}") - -############################################################################################# -### enable parallel builds - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=ON") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=OFF") - -############################################################################################# -### enable thread-safety builds - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_THREADSAFE:BOOL=ON") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PARALLEL:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_CPP_LIB:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_HL_LIB:BOOL=OFF") - -############################################################################################# -### disable test program builds - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=OFF") - -############################################################################################# -### disable packaging - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_NO_PACKAGES:BOOL=ON") -### Create install package with external libraries (szip, zlib) -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") - -#options to run test scripts in batch commands -set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") -set (LOCAL_BATCH_TEST "TRUE") -set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") - -############################################################################################# -### use a toolchain file - -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/intel.cmake") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/crayle.cmake") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/GCC.cmake") - -#some additions and alternatives to cross compile on haswell for knl -#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") -#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") -#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") - -############################################################################################# -- cgit v0.12 From 648a21473f078697630b4cbde43da68bb97be277 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 8 Feb 2019 21:38:39 -0600 Subject: Use correct values for other file versions --- config/cmake/scripts/HPC/bsub-HDF5options.cmake | 10 +++++----- config/cmake/scripts/HPC/raybsub-HDF5options.cmake | 14 +++++++------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config/cmake/scripts/HPC/bsub-HDF5options.cmake b/config/cmake/scripts/HPC/bsub-HDF5options.cmake index 5316f41..a862a6b 100644 --- a/config/cmake/scripts/HPC/bsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/bsub-HDF5options.cmake @@ -28,13 +28,13 @@ if (DEFINED MPI) endif () ############################################################################################# ### options to run test scripts in batch commands -set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") +set (LOCAL_BATCH_SCRIPT_COMMAND "bsub") set (LOCAL_BATCH_TEST "TRUE") -set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") -set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +set (LOCAL_BATCH_SCRIPT_NAME "ctestS.lsf") +set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.lsf") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.lsf") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.lsf") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") diff --git a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake index 5316f41..d3c8721 100644 --- a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake @@ -28,15 +28,15 @@ if (DEFINED MPI) endif () ############################################################################################# ### options to run test scripts in batch commands -set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") +set (LOCAL_BATCH_SCRIPT_COMMAND "raybsub") set (LOCAL_BATCH_TEST "TRUE") -set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") -set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +set (LOCAL_BATCH_SCRIPT_NAME "ray_ctestS.lsf") +set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ray_ctestP.lsf") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ray_ctestS.lsf") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ray_ctestP.lsf") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=mpirun") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-np") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") ############################################################################################# -- cgit v0.12 From 742894ce88b127d38dbaf91a3c8ad1c0f01f9b01 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 08:56:14 -0600 Subject: Add new cmake copy file tests to ignore --- config/cmake/CTestCustom.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/config/cmake/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 27eaa56..2333f67 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -64,11 +64,19 @@ set (CTEST_CUSTOM_MEMCHECK_IGNORE CPP_testhdf5-clear-objects ######### tools/h5clear ######### H5CLEAR-clearall-objects + H5CLEAR-copy_h5clear_fsm_persist_equal.h5 + H5CLEAR-copy_h5clear_fsm_persist_greater.h5 + H5CLEAR-copy_h5clear_fsm_persist_less.h5 + H5CLEAR-copy_h5clear_fsm_persist_noclose.h5 + H5CLEAR-copy_h5clear_fsm_persist_user_equal.h5 + H5CLEAR-copy_h5clear_fsm_persist_user_greater.h5 + H5CLEAR-copy_h5clear_fsm_persist_user_less.h5 H5CLEAR-copy_h5clear_log_v3.h5 H5CLEAR-copy_h5clear_mdc_image.h5 H5CLEAR-copy_h5clear_sec2_v0.h5 H5CLEAR-copy_h5clear_sec2_v2.h5 H5CLEAR-copy_h5clear_sec2_v3.h5 + H5CLEAR-copy_h5clear_status_noclear.h5 H5CLEAR-copy_latest_h5clear_log_v3.h5 H5CLEAR-copy_latest_h5clear_sec2_v3.h5 H5CLEAR-copy_mod_h5clear_mdc_image.h5 -- cgit v0.12 From 691b92ff9c8429cd704e482628ceb5438df1aca1 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 10:09:32 -0600 Subject: Set the full generator name --- config/cmake/scripts/HDF5config.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/cmake/scripts/HDF5config.cmake b/config/cmake/scripts/HDF5config.cmake index fda9fcc..bcd33df 100644 --- a/config/cmake/scripts/HDF5config.cmake +++ b/config/cmake/scripts/HDF5config.cmake @@ -45,7 +45,7 @@ set (CTEST_SOURCE_VERSEXT "") #CTEST_SOURCE_NAME - name of source folder; HDF5-1.10.0 #MODEL - CDash group name #HPC - run alternate configurations for HPC machines; sbatch, bsub, raybsub -#MPI - enable MPI; +#MPI - enable MPI; if (DEFINED CTEST_SCRIPT_ARG) # transform ctest script arguments of the form # script.ctest,var1=value1,var2=value2 @@ -174,6 +174,7 @@ if (NOT DEFINED HPC) endif () endif () else () + set (CTEST_CMAKE_GENERATOR "Unix Makefiles") include (${CTEST_SOURCE_DIRECTORY}/config/cmake/scripts/HPC/${HPC}-HDF5options.cmake) endif () ################################################################### -- cgit v0.12 From f7bab665bbb97f0ef01ef986d0dfa7932100de78 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 10:53:13 -0600 Subject: Distinguish parallel performance tests --- tools/test/perform/CMakeTests.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 5abd038..02dc15d 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -170,9 +170,9 @@ endif () set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects") if (H5_HAVE_PARALLEL) - add_test (NAME PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () -- cgit v0.12 From cc6a61215e508d047ed6aa2daf67475cfe34ee4d Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Mon, 11 Feb 2019 10:58:58 -0600 Subject: Re-write of Java JNI error handling --- java/src/jni/CMakeLists.txt | 26 + java/src/jni/Makefile.am | 5 +- java/src/jni/exceptionImp.c | 206 +- java/src/jni/h5Constants.c | 2 +- java/src/jni/h5Imp.c | 110 +- java/src/jni/h5aImp.c | 2710 ++++++++------- java/src/jni/h5dImp.c | 2566 +++++++------- java/src/jni/h5eImp.c | 583 ++-- java/src/jni/h5fImp.c | 585 ++-- java/src/jni/h5fImp.h | 2 +- java/src/jni/h5gImp.c | 224 +- java/src/jni/h5iImp.c | 233 +- java/src/jni/h5jni.h | 382 ++- java/src/jni/h5lImp.c | 869 ++--- java/src/jni/h5oImp.c | 936 ++--- java/src/jni/h5pACPLImp.c | 36 + java/src/jni/h5pACPLImp.h | 27 + java/src/jni/h5pDAPLImp.c | 322 ++ java/src/jni/h5pDAPLImp.h | 112 + java/src/jni/h5pDCPLImp.c | 1404 ++++++++ java/src/jni/h5pDCPLImp.h | 396 +++ java/src/jni/h5pDXPLImp.c | 502 +++ java/src/jni/h5pDXPLImp.h | 209 ++ java/src/jni/h5pFAPLImp.c | 1624 +++++++++ java/src/jni/h5pFAPLImp.h | 501 +++ java/src/jni/h5pFCPLImp.c | 572 ++++ java/src/jni/h5pFCPLImp.h | 207 ++ java/src/jni/h5pGAPLImp.c | 36 + java/src/jni/h5pGAPLImp.h | 27 + java/src/jni/h5pGCPLImp.c | 227 ++ java/src/jni/h5pGCPLImp.h | 99 + java/src/jni/h5pImp.c | 6234 ++++------------------------------ java/src/jni/h5pImp.h | 1554 +-------- java/src/jni/h5pLAPLImp.c | 237 ++ java/src/jni/h5pLAPLImp.h | 107 + java/src/jni/h5pLCPLImp.c | 36 + java/src/jni/h5pLCPLImp.h | 27 + java/src/jni/h5pOCPLImp.c | 211 ++ java/src/jni/h5pOCPLImp.h | 99 + java/src/jni/h5pOCpyPLImp.c | 92 + java/src/jni/h5pOCpyPLImp.h | 61 + java/src/jni/h5pStrCPLImp.c | 74 + java/src/jni/h5pStrCPLImp.h | 45 + java/src/jni/h5plImp.c | 177 +- java/src/jni/h5rImp.c | 399 ++- java/src/jni/h5sImp.c | 1661 +++++---- java/src/jni/h5tImp.c | 1444 ++++---- java/src/jni/h5util.c | 4732 ++++++++++++++------------ java/src/jni/h5util.h | 33 +- java/src/jni/h5vlImp.c | 148 +- java/src/jni/h5vlImp.h | 2 +- java/src/jni/h5zImp.c | 29 +- java/src/jni/nativeData.c | 1342 ++++---- java/test/TestH5.java | 17 + java/test/testfiles/JUnit-TestH5.txt | 3 +- src/H5Torder.c | 4 +- 56 files changed, 18289 insertions(+), 16219 deletions(-) create mode 100644 java/src/jni/h5pACPLImp.c create mode 100644 java/src/jni/h5pACPLImp.h create mode 100644 java/src/jni/h5pDAPLImp.c create mode 100644 java/src/jni/h5pDAPLImp.h create mode 100644 java/src/jni/h5pDCPLImp.c create mode 100644 java/src/jni/h5pDCPLImp.h create mode 100644 java/src/jni/h5pDXPLImp.c create mode 100644 java/src/jni/h5pDXPLImp.h create mode 100644 java/src/jni/h5pFAPLImp.c create mode 100644 java/src/jni/h5pFAPLImp.h create mode 100644 java/src/jni/h5pFCPLImp.c create mode 100644 java/src/jni/h5pFCPLImp.h create mode 100644 java/src/jni/h5pGAPLImp.c create mode 100644 java/src/jni/h5pGAPLImp.h create mode 100644 java/src/jni/h5pGCPLImp.c create mode 100644 java/src/jni/h5pGCPLImp.h create mode 100644 java/src/jni/h5pLAPLImp.c create mode 100644 java/src/jni/h5pLAPLImp.h create mode 100644 java/src/jni/h5pLCPLImp.c create mode 100644 java/src/jni/h5pLCPLImp.h create mode 100644 java/src/jni/h5pOCPLImp.c create mode 100644 java/src/jni/h5pOCPLImp.h create mode 100644 java/src/jni/h5pOCpyPLImp.c create mode 100644 java/src/jni/h5pOCpyPLImp.h create mode 100644 java/src/jni/h5pStrCPLImp.c create mode 100644 java/src/jni/h5pStrCPLImp.h diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index 00c2b34..42b4a48 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -14,6 +14,19 @@ set (HDF5_JAVA_JNI_CSRCS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5lImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5oImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pACPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDAPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDCPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDXPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pFAPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pFCPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pGAPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pGCPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pLAPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pLCPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pOCPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pOCpyPLImp.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pStrCPLImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5plImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5rImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.c @@ -36,6 +49,19 @@ set (HDF5_JAVA_JNI_CHDRS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5lImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5oImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pACPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDAPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDCPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pDXPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pFAPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pFCPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pGAPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pGCPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pLAPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pLCPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pOCPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pOCpyPLImp.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5pStrCPLImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5plImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5rImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.h diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am index 370b08b..1ec9b94 100644 --- a/java/src/jni/Makefile.am +++ b/java/src/jni/Makefile.am @@ -34,7 +34,10 @@ libhdf5_java_la_LDFLAGS = -avoid-version -shared -export-dynamic -version-info $ # Source files for the library libhdf5_java_la_SOURCES=exceptionImp.c h5Constants.c nativeData.c h5util.c h5Imp.c \ h5aImp.c h5dImp.c h5eImp.c h5fImp.c h5gImp.c h5iImp.c h5lImp.c h5oImp.c \ - h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5vlImp.c h5zImp.c + h5pImp.c h5pACPLImp.c h5pDAPLImp.c h5pDCPLImp.c h5pDXPLImp.c \ + h5pFAPLImp.c h5pFCPLImp.c h5pGAPLImp.c h5pGCPLImp.c h5pLAPLImp.c h5pLCPLImp.c \ + h5pOCPLImp.c h5pOCpyPLImp.c h5pStrCPLImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c \ + h5vlImp.c h5zImp.c # HDF5 Java (JNI) library depends on HDF5 Library. libhdf5_java_la_LIBADD=$(LIBHDF5) diff --git a/java/src/jni/exceptionImp.c b/java/src/jni/exceptionImp.c index ccda0d2..0faa0cc 100644 --- a/java/src/jni/exceptionImp.c +++ b/java/src/jni/exceptionImp.c @@ -33,21 +33,14 @@ extern "C" { #include "h5jni.h" #include "exceptionImp.h" -extern H5E_auto2_t efunc; -extern void *edata; +extern H5E_auto2_t efunc; +extern void *edata; /*******************/ /* Local Variables */ /*******************/ -/* These types are copied from H5Eprivate.h - * They should be moved to a public include file, and deleted from - * here. - */ - -#define H5E_NSLOTS 32 /*number of slots in an error stack */ - /* * The list of error messages in the system is kept as an array of * error_code/message pairs, one for major error numbers and another for @@ -73,29 +66,29 @@ typedef struct H5E_num_t { /* Local Macros */ /********************/ -#define THROWEXCEPTION(className,args) { \ - jclass jc; \ - jmethodID jm; \ - jobject ex; \ - jc = ENVPTR->FindClass(ENVPAR (className)); \ - if (jc == NULL) { \ - return JNI_FALSE; \ - } \ - jm = ENVPTR->GetMethodID(ENVPAR jc, "", "(Ljava/lang/String;)V"); \ - if (jm == NULL) { \ - printf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \ - return JNI_FALSE; \ - } \ - ex = ENVPTR->NewObjectA (ENVPAR jc, jm, (jvalue*)(args)); \ - if (ex == NULL) { \ - printf("THROWEXCEPTION FATAL ERROR: %s: Creation failed\n", (className)); \ - return JNI_FALSE; \ - } \ - if (ENVPTR->Throw(ENVPAR (jthrowable)ex) < 0) { \ - printf("THROWEXCEPTION FATAL ERROR: %s: Throw failed\n", (className)); \ - return JNI_FALSE; \ - } \ - return JNI_TRUE; \ +#define THROWEXCEPTION(className, args) \ +{ \ + jmethodID jm; \ + jclass jc; \ + jobject ex; \ + \ + if (NULL == (jc = ENVPTR->FindClass(ENVONLY, (className)))) \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + \ + if (NULL == (jm = ENVPTR->GetMethodID(ENVONLY, jc, "", "(Ljava/lang/String;)V"))) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: GetMethodID failed\n"); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ + \ + if (NULL == (ex = ENVPTR->NewObjectA(ENVONLY, jc, jm, (jvalue *)(args)))) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Creation failed\n", (className)); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ + \ + if (ENVPTR->Throw(ENVONLY, (jthrowable)ex) < 0) { \ + HDprintf("THROWEXCEPTION FATAL ERROR: Class %s: Throw failed\n", (className)); \ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); \ + } \ } /********************/ @@ -112,7 +105,9 @@ walk_error_callback { H5E_num_t *err_nums = (H5E_num_t *)_err_nums; - if(err_desc) { + UNUSED(n); + + if (err_desc) { err_nums->maj_num = err_desc->maj_num; err_nums->min_num = err_desc->min_num; } /* end if */ @@ -130,8 +125,15 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5error_1off (JNIEnv *env, jclass clss) { - H5Eget_auto2(H5E_DEFAULT, &efunc, &edata); - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + UNUSED(env); + UNUSED(clss); + + if (H5Eget_auto2(H5E_DEFAULT, &efunc, &edata) < 0) + return -1; + + if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0) + return -1; + return 0; } /* end Java_hdf_hdf5lib_H5_H5error_1off() */ @@ -145,10 +147,12 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5error_1on (JNIEnv *env, jclass clss) { + UNUSED(env); + UNUSED(clss); + H5Eset_auto2(H5E_DEFAULT, efunc, edata); } /* end Java_hdf_hdf5lib_H5_H5error_1on() */ - /* * Class: hdf_hdf5lib_exceptions_HDFLibraryException * Method: printStackTrace0 @@ -163,18 +167,25 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0 FILE *stream = NULL; const char *file = NULL; - if(file_name == NULL) { + UNUSED(obj); + + if (NULL == file_name) { H5Eprint2(H5E_DEFAULT, stderr); - } /* end if */ + } else { - file = ENVPTR->GetStringUTFChars(ENVPAR file_name, 0); - stream = HDfopen(file, "a+"); - if(stream) { + PIN_JAVA_STRING(ENVONLY, file_name, file, NULL, "printStackTrace0: file name not pinned"); + + if ((stream = HDfopen(file, "a+"))) { H5Eprint2(H5E_DEFAULT, stream); HDfclose(stream); - } /* end if */ - ENVPTR->ReleaseStringUTFChars(ENVPAR file_name, file); - } /* end else */ + } + } + +done: + if (file) + UNPIN_JAVA_STRING(ENVONLY, file_name, file); + + return; } /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException_printStackTrace0() */ /* @@ -189,10 +200,15 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber (JNIEnv *env, jobject obj) { H5E_num_t err_nums; + + UNUSED(env); + UNUSED(obj); + err_nums.maj_num = 0; err_nums.min_num = 0; - H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums); + if (H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums) < 0) + return -1; return err_nums.maj_num; } /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMajorErrorNumber() */ @@ -209,27 +225,42 @@ Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber (JNIEnv *env, jobject obj) { H5E_num_t err_nums; + + UNUSED(env); + UNUSED(obj); + err_nums.maj_num = 0; err_nums.min_num = 0; - H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums); + if (H5Ewalk2(H5E_DEFAULT, H5E_WALK_DOWNWARD, walk_error_callback, &err_nums) < 0) + return -1; return err_nums.min_num; } /* end Java_hdf_hdf5lib_exceptions_HDF5LibraryException__1getMinorErrorNumber() */ /* - * Routine to raise particular Java exceptions from C + * Routine to raise particular Java exceptions from C. */ static jboolean H5JNIErrorClass (JNIEnv *env, const char *message, const char *className) { - char *args[2]; - jstring str = ENVPTR->NewStringUTF(ENVPAR message); - args[0] = (char *)str; + jstring str; + char *args[2]; + jboolean retVal = JNI_FALSE; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, message))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + args[0] = (char *) str; args[1] = 0; THROWEXCEPTION(className, args); + + retVal = JNI_TRUE; + +done: + return retVal; } /* end H5JNIErrorClass() */ /* @@ -316,7 +347,7 @@ h5unimplemented */ jboolean h5raiseException - (JNIEnv *env, const char *exception, const char *message) + (JNIEnv *env, const char *message, const char *exception) { return H5JNIErrorClass(env, message, exception); } /* end h5raiseException() */ @@ -336,51 +367,76 @@ jboolean h5libraryError (JNIEnv *env) { - char *args[2]; const char *exception = NULL; - char *msg_str = NULL; - int num_errs = 0; - hid_t min_num; - hid_t maj_num; - ssize_t msg_size = 0; H5E_type_t error_msg_type; - jstring str = NULL; - hid_t stk_id = -1; H5E_num_t exceptionNumbers; + jstring str = NULL; + ssize_t msg_size = 0; + hid_t min_num; + hid_t maj_num; + hid_t stk_id = H5I_INVALID_HID; + char *args[2]; + char *msg_str = NULL; + jboolean retVal = JNI_FALSE; exceptionNumbers.maj_num = 0; exceptionNumbers.min_num = 0; /* Save current stack contents for future use */ - stk_id = H5Eget_current_stack(); /* This will clear current stack */ - if(stk_id >= 0) - H5Ewalk2(stk_id, H5E_WALK_DOWNWARD, walk_error_callback, &exceptionNumbers); + if ((stk_id = H5Eget_current_stack()) >= 0) + /* This will clear current stack */ + if (H5Ewalk2(stk_id, H5E_WALK_DOWNWARD, walk_error_callback, &exceptionNumbers) < 0) + goto done; + maj_num = exceptionNumbers.maj_num; min_num = exceptionNumbers.min_num; + /* + * TODO: handle < 0 case. + */ + + /* + * No error detected in HDF5 error stack. + */ + if (!maj_num && !min_num) + goto done; + exception = defineHDF5LibraryException(maj_num); /* get the length of the name */ - msg_size = H5Eget_msg(min_num, NULL, NULL, 0); - if(msg_size > 0) { - msg_size++; /* add extra space for the null terminator */ - msg_str = (char*)HDcalloc((size_t)msg_size, sizeof(char)); - if(msg_str) { - msg_size = H5Eget_msg(min_num, &error_msg_type, (char *)msg_str, (size_t)msg_size); - str = ENVPTR->NewStringUTF(ENVPAR msg_str); - HDfree(msg_str); - } /* end if */ - } /* end if */ + if ((msg_size = H5Eget_msg(min_num, NULL, NULL, 0)) < 0) + goto done; + + if (msg_size > 0) { + if (NULL == (msg_str = (char *) HDcalloc((size_t)msg_size + 1, sizeof(char)))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5libraryerror: failed to allocate buffer for error message"); + + if ((msg_size = H5Eget_msg(min_num, &error_msg_type, msg_str, (size_t)msg_size + 1)) < 0) + goto done; + msg_str[msg_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, msg_str))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } else str = NULL; - if(stk_id >= 0) + + if (stk_id >= 0) H5Eset_current_stack(stk_id); - args[0] = (char *)str; + args[0] = (char *) str; args[1] = 0; + THROWEXCEPTION(exception, args); -} /* end h5libraryError() */ + retVal = JNI_TRUE; + +done: + if (msg_str) + HDfree(msg_str); + + return retVal; +} /* end h5libraryError() */ /* * defineHDF5LibraryException() returns the name of the sub-class diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index e88fa55..2ac0892 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -1260,7 +1260,7 @@ Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass c JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) { return H5VL_NATIVE; } JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVPAR H5VL_NATIVE_NAME); } +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVONLY, H5VL_NATIVE_NAME); } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VALUE; } JNIEXPORT jint JNICALL diff --git a/java/src/jni/h5Imp.c b/java/src/jni/h5Imp.c index 1ad6b17..99c91fd 100644 --- a/java/src/jni/h5Imp.c +++ b/java/src/jni/h5Imp.c @@ -35,7 +35,10 @@ extern "C" { #include "h5jni.h" #include "h5Imp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -46,10 +49,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5open (JNIEnv *env, jclass clss) { - herr_t retVal = H5open(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + if ((retVal = H5open()) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5open */ @@ -62,10 +69,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5close (JNIEnv *env, jclass clss) { - herr_t retVal = H5close(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5close()) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5close */ @@ -78,10 +89,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5dont_1atexit (JNIEnv *env, jclass clss) { - herr_t retVal = H5dont_atexit(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + UNUSED(clss); + + if ((retVal = H5dont_atexit()) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5dont_1atexit */ @@ -94,29 +109,25 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5get_1libversion (JNIEnv *env, jclass clss, jintArray libversion) { - unsigned *theArray = NULL; - herr_t status = -1; - jboolean isCopy; - - if (libversion == NULL) { - h5nullArgument(env, "H5get_version: libversion is NULL"); - } /* end if */ - else { - theArray = (unsigned*)ENVPTR->GetIntArrayElements(ENVPAR libversion, &isCopy); - if (theArray == NULL) { - h5JNIFatalError( env, "H5get_libversion: input not pinned"); - } /* end if */ - else { - status = H5get_libversion(&(theArray[0]), &(theArray[1]), &(theArray[2])); - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - ENVPTR->ReleaseIntArrayElements(ENVPAR libversion, (jint*)theArray,0); - } /* end else */ - } /* end else */ - return (jint)status; + jboolean libversionArrayIsCopy; + int *libversionArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (libversion == NULL) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5get_libversion: libversion is NULL"); + + PIN_INT_ARRAY(ENVONLY, libversion, libversionArray, &libversionArrayIsCopy, "H5get_libversion: libversion input not pinned"); + + if ((status = H5get_libversion((unsigned *) &(libversionArray[0]), (unsigned *) &(libversionArray[1]), (unsigned *) &(libversionArray[2]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (libversionArray) + UNPIN_INT_ARRAY(ENVONLY, libversion, libversionArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5get_1libversion */ /* @@ -128,6 +139,9 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5check_1version (JNIEnv *env, jclass clss, jint majnum, jint minnum, jint relnum) { + UNUSED(env); + UNUSED(clss); + return (jint)H5check_version((unsigned)majnum, (unsigned)minnum, (unsigned)relnum); } /* end Java_hdf_hdf5lib_H5_H5check_1version */ @@ -141,10 +155,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5garbage_1collect (JNIEnv *env, jclass clss) { - herr_t retVal = H5garbage_collect(); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5garbage_collect()) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5garbage_1collect */ @@ -158,11 +176,15 @@ Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits (JNIEnv *env, jclass clss, jint reg_global_lim, jint reg_list_lim, jint arr_global_lim, jint arr_list_lim, jint blk_global_lim, jint blk_list_lim ) { - herr_t retVal = 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); - if (retVal < 0) - h5libraryError(env); + herr_t retVal = FAIL; + UNUSED(clss); + + if ((retVal = 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)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5set_1free_1list_1limits */ @@ -176,7 +198,13 @@ Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe (JNIEnv *env, jclass clss) { hbool_t is_ts = false; - H5is_library_threadsafe(&is_ts); + + UNUSED(clss); + + if (H5is_library_threadsafe(&is_ts) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jboolean)is_ts; } /* end Java_hdf_hdf5lib_H5_H5is_1library_1threadsafe */ diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index e0ec4ca..666626f 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -21,13 +21,17 @@ extern "C" { #endif /* __cplusplus */ -#include "hdf5.h" -#include "h5util.h" #include #include #include +#include "hdf5.h" +#include "h5util.h" +#include "h5jni.h" #include "h5aImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; typedef struct _cb_wrapper { @@ -35,28 +39,14 @@ typedef struct _cb_wrapper { jobject op_data; } cb_wrapper; -#ifdef __cplusplus -#define CBENVPTR (cbenv) -#define CBENVPAR -#define JVMPTR (jvm) -#define JVMPAR -#define JVMPAR2 -#else -#define CBENVPTR (*cbenv) -#define CBENVPAR cbenv, -#define JVMPTR (*jvm) -#define JVMPAR jvm -#define JVMPAR2 jvm, -#endif - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5AwriteVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); -static herr_t H5AwriteVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); -static herr_t H5AreadVL_asstr (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); -static herr_t H5AreadVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); +static herr_t H5AwriteVL_asstr(JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); +static herr_t H5AwriteVL_str(JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); +static herr_t H5AreadVL_asstr(JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); +static herr_t H5AreadVL_str(JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectArray buf); static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data); @@ -64,90 +54,6 @@ static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *inf /* Local Macros */ /********************/ -#define PIN_BYTE_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_BYTE_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_SHORT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_SHORT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_INT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_INT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_LONG_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \ -} - -#define UNPIN_LONG_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_FLOAT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_FLOAT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_DOUBLE_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_DOUBLE_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \ -} - /* * Class: hdf_hdf5lib_H5 @@ -159,18 +65,22 @@ Java_hdf_hdf5lib_H5__1H5Acreate (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, jlong space_id, jlong create_plist) { - hid_t attr_id = -1; - const char *aName; + const char *attrName = NULL; + hid_t attr_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - attr_id = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT); + UNUSED(clss); - UNPIN_JAVA_STRING(name, aName); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Acreate: attribute name is NULL"); - if (attr_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Acreate: attribute name not pinned"); + + if ((attr_id = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, (hid_t)space_id, (hid_t)create_plist, (hid_t)H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, name, attrName); return (jlong)attr_id; } /* end Java_hdf_hdf5lib_H5__1H5Acreate */ @@ -184,18 +94,22 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name) { - hid_t attr_id = -1; - const char *aName; + const char *attrName = NULL; + hid_t attr_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - attr_id = H5Aopen_name((hid_t)loc_id, aName); + UNUSED(clss); - UNPIN_JAVA_STRING(name,aName); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen_name: attribute name is null"); - if (attr_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Aopen_name: attribute name not pinned"); + + if((attr_id = H5Aopen_name((hid_t)loc_id, attrName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, name, attrName); return (jlong)attr_id; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1name */ @@ -209,39 +123,17 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1idx (JNIEnv *env, jclass clss, jlong loc_id, jint idx) { - hid_t attr_id = H5Aopen_idx((hid_t)loc_id, (unsigned int) idx); + hid_t attr_id = H5I_INVALID_HID; - if (attr_id < 0) - h5libraryError(env); + UNUSED(clss); + if ((attr_id = H5Aopen_idx((hid_t) loc_id, (unsigned int) idx)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)attr_id; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1idx */ -static htri_t -H5Tdetect_variable_str - (hid_t tid) { - htri_t ret_val = 0; - - if (H5Tget_class(tid) == H5T_COMPOUND) { - unsigned i; - unsigned nm = (unsigned)H5Tget_nmembers(tid); - for(i = 0; i < nm; i++) { - htri_t status = 0; - hid_t mtid = 0; - if((mtid = H5Tget_member_type(tid, i)) < 0) - return -1; /* exit immediately on error */ - if((status = H5Tdetect_variable_str(mtid)) < 0) - return status; /* exit immediately on error */ - ret_val |= status; - H5Tclose (mtid); - } /* end for */ - } /* end if */ - else - ret_val = H5Tis_variable_str(tid); - - return ret_val; -} /* end H5Tdetect_variable_str */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Aread @@ -251,46 +143,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jbyte *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument( env,"H5Aread: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + jbyte *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread: variable length type not supported"); + + if (isCriticalPinning) { + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread: buf does not support variable length type"); - } /* end else if */ + PIN_BYTE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_BYTE_ARRAY(); - - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - if (status < 0) { - UNPIN_BYTE_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_BYTE_ARRAY(0); /* update java buffer for return */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_BYTE_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread */ @@ -304,43 +198,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jbyte *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument( env,"H5Awrite: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Awrite: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jbyte *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite: variable length type not supported"); + + if (isCriticalPinning) { + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite: buf does not support variable length type"); - } /* end else if */ - else { - PIN_BYTE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); + PIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite: write buffer not pinned"); + } - UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */ + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + else { + UNPIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite */ @@ -354,46 +253,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1short (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jshort *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Aread_short: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_short: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + jshort *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_short: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_short: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_short: variable length type not supported"); + + if (isCriticalPinning) { + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_short: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread_short: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_short: buf does not support variable length type"); - } /* end else if */ + PIN_SHORT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_short: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_SHORT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread_short: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - if (status < 0) { - UNPIN_SHORT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_SHORT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_SHORT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1short */ @@ -407,43 +308,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1short (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jshort *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL ) { - h5nullArgument(env, "H5Awrite_short: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_short: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jshort *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_short: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_short: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_short: variable length type not supported"); + + if (isCriticalPinning) { + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_short: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_short: buf does not support variable length type"); - } /* end else if */ - else { - PIN_SHORT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite_short: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); + PIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_short: write buffer not pinned"); + } - UNPIN_SHORT_ARRAY(JNI_ABORT); + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + else { + UNPIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1short */ @@ -457,46 +363,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1int (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jint *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Aread_int: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Aread_int: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_int: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + htri_t data_class; + jint *readBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (buf == NULL) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_int: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_int: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_int: variable length type not supported"); + + if (isCriticalPinning) { + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_int: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread_int: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_int: buf does not support variable length type"); - } /* end else if */ + PIN_INT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_int: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_INT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread_int: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - if (status < 0) { - UNPIN_INT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_INT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_INT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1int */ @@ -510,43 +418,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1int (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jint *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Awrite_int: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_int: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jint *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (buf == NULL) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_int: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_int: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_int: variable length type not supported"); + + if (isCriticalPinning) { + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_int: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_int: buf does not support variable length type"); - } /* end else if */ - else { - PIN_INT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite_int: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); + PIN_INT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_int: write buffer not pinned"); + } - UNPIN_INT_ARRAY(JNI_ABORT); + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + else { + UNPIN_INT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1int */ @@ -560,46 +473,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1long (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jlong *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Aread_long: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Aread_long: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_long: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + jlong *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_long: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_long: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_long: variable length type not supported"); + + if (isCriticalPinning) { + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_long: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread_long: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_long: buf does not support variable length type"); - } /* end else if */ + PIN_LONG_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_long: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_LONG_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread_long: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - if (status < 0) { - UNPIN_LONG_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_LONG_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_LONG_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1long */ @@ -613,42 +528,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1long (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jlong *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Awrite_long: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_long: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jlong *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_long: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_long: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_long: variable length type not supported"); + + if (isCriticalPinning) { + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_long: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite_long: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_long: buf does not support variable length type"); - } /* end else if */ + PIN_LONG_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_long: write buffer not pinned"); + } + + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_LONG_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite_long: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - UNPIN_LONG_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_LONG_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1long */ @@ -662,46 +583,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1float (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jfloat *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Aread_float: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_float: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + jfloat *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_float: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_float: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_float: variable length type not supported"); + + if (isCriticalPinning) { + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_float: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread_float: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_float: buf does not support variable length type"); - } /* end else if */ + PIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_float: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_FLOAT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread_float: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - if (status < 0) { - UNPIN_FLOAT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_FLOAT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1float */ @@ -715,42 +638,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1float (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jfloat *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Awrite_float: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_float: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jfloat *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_float: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_float: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_float: variable length type not supported"); + + if (isCriticalPinning) { + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_float: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_float: buf does not support variable length type"); - } /* end else if */ + PIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_float: write buffer not pinned"); + } + + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_FLOAT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite_float: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - UNPIN_FLOAT_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1float */ @@ -764,46 +693,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1double (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jdouble *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Aread_double: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Aread_double: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_double: buf does not support variable length type"); - } /* end else if */ + jboolean readBufIsCopy; + jdouble *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_double: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_double: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_double: variable length type not supported"); + + if (isCriticalPinning) { + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_double: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Aread_double: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Aread_double: buf does not support variable length type"); - } /* end else if */ + PIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Aread_double: read buffer not pinned"); + } + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_DOUBLE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Aread_double: buf not pinned"); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - if (status < 0) { - UNPIN_DOUBLE_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_DOUBLE_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1double */ @@ -817,42 +748,48 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1double (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jdouble *buffP; - jboolean isCopy; - htri_t data_class; - - if (buf == NULL) { - h5nullArgument(env, "H5Awrite_double: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_double: buf does not support variable length type"); - } /* end else if */ + jboolean writeBufIsCopy; + jdouble *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_double: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_double: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_double: variable length type not supported"); + + if (isCriticalPinning) { + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_double: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Awrite_double: buf does not support variable length type"); - } /* end else if */ + PIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Awrite_double: write buffer not pinned"); + } + + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_DOUBLE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Awrite_double: buf not pinned"); - } /* end if */ - else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - - UNPIN_DOUBLE_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1double */ @@ -866,67 +803,58 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1string (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) { - herr_t status = -1; - char *c_buf; - char *cstr; - size_t str_len; - jsize i; - jsize n; - size_t pos; - jstring jstr; - - c_buf = cstr = NULL; - if (j_buf == NULL) { - h5nullArgument(env, "H5Aread_string: buf is NULL"); - } /* end if */ - else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { - h5nullArgument(env, "H5Aread_string: buf length <= 0"); - } /* end else if */ - else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) { - h5libraryError(env); - } /* end else if */ - else { - if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) { - h5JNIFatalError(env, "H5Aread_string: memory allocation failed."); - } /* end if */ - else { - if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) { - if (cstr) - HDfree(cstr); - cstr = NULL; - h5JNIFatalError(env, "H5Aread_string: memory allocation failed."); - } /* end if */ - else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf); - - if (status < 0) { - if (cstr) - HDfree(cstr); - cstr = NULL; - if (c_buf) - HDfree(c_buf); - c_buf = NULL; - h5libraryError(env); - } /* end if */ - else { - pos = 0; - for (i = 0; i < n; i++) { - HDmemcpy(cstr, c_buf+pos, str_len); - cstr[str_len] = '\0'; - jstr = ENVPTR->NewStringUTF(ENVPAR cstr); - ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr); - pos += str_len; - } /* end for */ - } /* end else */ - - if (c_buf) - HDfree(c_buf); - } /* end else cbuf allocation*/ - - if (cstr) - HDfree(cstr); - } /* end else cstr allocation*/ - } /* end else */ + jstring jstr; + size_t str_len; + size_t pos; + jsize i, n; + char *c_buf = NULL; + char *cstr = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == j_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aread_string: read buffer is NULL"); + + if ((n = ENVPTR->GetArrayLength(ENVONLY, j_buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_string: read buffer length <= 0"); + } + + if (!(str_len = H5Tget_size((hid_t)mem_type_id))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + + if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: memory allocation failed"); + + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0, pos = 0; i < n; i++) { + HDmemcpy(cstr, c_buf+pos, str_len); + cstr[str_len] = '\0'; + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_string: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + pos += str_len; + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (c_buf) + HDfree(c_buf); + if (cstr) + HDfree(cstr); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1string */ @@ -940,52 +868,63 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite_1string (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) { - herr_t status = -1; - char *c_buf; - jsize str_len; - jsize i; - jsize n; - - if (j_buf == NULL) { - h5nullArgument(env, "H5Awrite_string: buf is NULL"); - } /* end if */ - else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { - h5nullArgument(env, "H5Awrite_string: buf length <= 0"); - } /* end else if */ - else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) { - h5libraryError(env); - } /* end else if */ - else { - if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) { - h5JNIFatalError(env, "H5Awrite_string: memory allocation failed."); - } /* end if */ - else { - for (i = 0; i < n; i++) { - jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + const char *utf8 = NULL; + jstring obj; + size_t i, str_len; + jsize n; + char *c_buf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == j_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Awrite_string: write buffer is NULL"); - if (utf8) { - HDstrncpy(&c_buf[i * str_len], utf8, str_len); - } /* end if */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, j_buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Awrite_string: write buffer length <= 0"); + } + + if (!(str_len = H5Tget_size((hid_t)mem_type_id))) + H5_LIBRARY_ERROR(ENVONLY); - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for */ + if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Awrite_string: memory allocation failed"); - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, c_buf); + for (i = 0; i < (size_t) n; i++) { + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + HDmemset(&c_buf[i * str_len], 0, str_len); + continue; + } + + /* + * length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + * CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + */ + + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5Awrite_string: string not pinned"); + + HDstrncpy(&c_buf[i * str_len], utf8, str_len); + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } /* end for */ - if (c_buf) - HDfree(c_buf); - c_buf = NULL; + if ((status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, c_buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) { - h5libraryError(env); - } /* end if */ - } /* end else */ - } /* end else */ +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + if (c_buf) + HDfree(c_buf); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1string */ @@ -999,167 +938,201 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadVL (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - herr_t status = -1; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - - if (buf == NULL) { - h5nullArgument(env, "H5AreadVL: buf is NULL"); - } /* end if */ - else { - isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { - unsigned i; - int nm = H5Tget_nmembers(mem_type_id); - for(i = 0; i 0 || isVlenStr) { - status = H5AreadVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); - } - else if (isStr > 0) { - status = H5AreadVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); + H5T_class_t type_class; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; + htri_t isComplex2 = 0; + hid_t nested_tid = H5I_INVALID_HID; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5AreadVL: read buffer is NULL"); + + if ((isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (type_class == H5T_COMPOUND) { + unsigned i; + int num_members; + + if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (unsigned) num_members; i++) { + if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + isComplex = isComplex || isComplex2; + + if (H5Tclose(nested_tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nested_tid = H5I_INVALID_HID; } - } /* end else */ + } + else if (type_class == H5T_VLEN) { + isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ + } + + if (!isStr || isComplex || isVlenStr) { + if ((status = H5AreadVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else if (isStr) { + if ((status = H5AreadVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (nested_tid >= 0) + H5Tclose(nested_tid); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1VL */ -herr_t -H5AreadVL_asstr +/* + * Helper method to read in a buffer of variable-length strings from an HDF5 + * attribute. Each C-string is converted to a Java string and set in the output + * buffer in turn. + */ +static herr_t +H5AreadVL_str (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - jint i; - jint n; - hid_t sid; - jstring jstr; - h5str_t h5str; - hvl_t *rdata; - hsize_t dims[H5S_MAX_RANK]; - size_t size; - size_t max_len = 0; - herr_t status = -1; + jstring jstr; + jsize i, n; + char **strs = NULL; + herr_t status = FAIL; - /* Get size of string array */ - n = ENVPTR->GetArrayLength(ENVPAR buf); - /* we will need to read n number of hvl_t structures */ - rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); - if (rdata == NULL) { - h5JNIFatalError(env, "H5AreadVL_asstr: failed to allocate buff for read"); - } /* end if */ - else { - status = H5Aread(aid, tid, rdata); - - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata); - H5Sclose(sid); - HDfree(rdata); - h5JNIFatalError(env, "H5AreadVL_asstr: failed to read data"); - } /* end if */ - else { - /* calculate the largest size of all the hvl_t structures read */ - max_len = 1; - for (i=0; i < n; i++) { - if ((rdata + i)->len > max_len) - max_len = (rdata + i)->len; - } - - /* create one malloc to hold largest element */ - size = H5Tget_size(tid) * max_len; - HDmemset(&h5str, 0, sizeof(h5str_t)); - h5str_new(&h5str, 4 * size); - - if (h5str.s == NULL) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata); - H5Sclose(sid); - HDfree(rdata); - h5JNIFatalError(env, "H5AreadVL_asstr: failed to allocate buf"); - } /* end if */ - else { - H5T_class_t tclass = H5Tget_class(tid); - /* convert each element to char string */ - for (i=0; i < n; i++) { - h5str.s[0] = '\0'; - h5str_vlsprintf(&h5str, aid, tid, rdata+i, 0); - jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - } /* end for */ - h5str_free(&h5str); - - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, rdata); - H5Sclose(sid); - HDfree(rdata); - } /* end else */ - } /* end else */ - } /* end else */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadVL_str: buf length < 0"); + } + + if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_str: failed to allocate variable length string read buffer"); + + if ((status = H5Aread(aid, tid, strs)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* + * When repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings), + * H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings + * once done. + */ + for (i = 0; i < n; i++) { + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, strs[i]))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + H5free_memory(strs[i]); + strs[i] = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (strs) { + for (i = 0; i < n; i++) { + if (strs[i]) + H5free_memory(strs[i]); + } + + HDfree(strs); + } return status; -} +} /* end H5AreadVL_str */ -herr_t -H5AreadVL_str +/* + * Helper method to read in a buffer of variable-length (hvl_t) + * structures from an HDF5 attribute and convert each variable-length + * element's buffer into a Java string. Each string is then set + * in the output buffer in turn. + */ +static herr_t +H5AreadVL_asstr (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - char **strs; - jstring jstr; - jint i; - jint n; - hid_t sid; - hsize_t dims[H5S_MAX_RANK]; - herr_t status = -1; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - strs =(char**)HDcalloc((size_t)n, sizeof(char*)); - - if (strs == NULL) { - h5JNIFatalError(env, "H5AreadVL_str: failed to allocate buff for read variable length strings"); - } /* end if */ - else { - status = H5Aread(aid, tid, strs); - - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); - H5Sclose(sid); - HDfree(strs); - h5JNIFatalError(env, "H5AreadVL_str: failed to read variable length strings"); - } /* end if */ - else { - for (i=0; i < n; i++) { - jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - H5free_memory (strs[i]); - } /* end for */ + hsize_t dims[H5S_MAX_RANK]; + jstring jstr; + h5str_t h5str; + size_t typeSize; + size_t i; + hid_t sid = H5I_INVALID_HID; + jsize n; + void *readBuf = NULL; + herr_t status = FAIL; - /* - for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, - H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect - free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings - after it is done. - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); - */ + HDmemset(&h5str, 0, sizeof(h5str_t)); + + /* Get size of string array */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadVL_asstr: buf length < 0"); + } + + dims[0] = (hsize_t)n; + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate read buffer"); - HDfree(strs); - } /* end else */ - } /* end else */ + if ((status = H5Aread(aid, tid, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Allocate a decent-sized initial string */ + h5str_new(&h5str, 4 * typeSize); + + if (!h5str.s) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadVL_asstr: failed to allocate buffer"); + + /* Convert each element to a char string */ + for (i = 0; i < (size_t) n; i++) { + h5str.s[0] = '\0'; + + if (!h5str_sprintf(ENVONLY, &h5str, aid, tid, &(((char *) readBuf)[i * typeSize]), typeSize, 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (h5str.s) + h5str_free(&h5str); + if (readBuf) { + H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, readBuf); + HDfree(readBuf); + } + if (sid >= 0) + H5Sclose(sid); return status; -} /* end H5AreadVL_str */ +} /* * Class: hdf_hdf5lib_H5 @@ -1170,139 +1143,224 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AwriteVL (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - herr_t status = -1; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; - - if (buf == NULL) { - h5nullArgument(env, "H5AwriteVL: buf is NULL"); - } /* end if */ - else { - isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { - unsigned i; - int nm = H5Tget_nmembers(mem_type_id); - for(i = 0; i 0 || isVlenStr) { - status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); - } - else if (isStr > 0) { - status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); + H5T_class_t type_class; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; + htri_t isComplex2 = 0; + hid_t nested_tid = H5I_INVALID_HID; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5AwriteVL: write buffer is NULL"); + + if ((isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (type_class == H5T_COMPOUND) { + unsigned i; + int num_members; + + if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for(i = 0; i < (unsigned) num_members; i++) { + if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + isComplex = isComplex || isComplex2; + + if (H5Tclose(nested_tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nested_tid = H5I_INVALID_HID; } - } /* end else */ + } + else if (type_class == H5T_VLEN) { + isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ + } + + if (!isStr || isComplex || isVlenStr) { + if ((status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else if (isStr) { + if ((status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (nested_tid >= 0) + H5Tclose(nested_tid); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */ -herr_t +/* + * Helper method to convert an array of Java strings into a buffer of C-strings. + * The buffer of C-strings is then written to the HDF5 attribute specified. + */ +static herr_t H5AwriteVL_str (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - herr_t status = -1; - char **wdata; - jsize size; - jint i; + const char *utf8 = NULL; + jstring obj; + jsize size; + jint i; + char **writeBuf = NULL; + herr_t status = FAIL; + + if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray) buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AwriteVL_str: buf length < 0"); + } - size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate variable length string write buffer") - wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); - if (!wdata) { - h5JNIFatalError(env, "H5AwriteVL_str: cannot allocate buffer"); - } /* end if */ - else { - HDmemset(wdata, 0, (size_t)size * sizeof(char*)); - for (i = 0; i < size; ++i) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); - - if (utf8) { - wdata[i] = (char*)HDmalloc((size_t)length + 1); - if (wdata[i]) { - HDmemset(wdata[i], 0, ((size_t)length + 1)); - HDstrncpy(wdata[i], utf8, (size_t)length); - } /* end if */ - } /* end if */ - - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for (i = 0; i < size; ++i) */ - - status = H5Awrite((hid_t)aid, (hid_t)tid, wdata); + for (i = 0; i < size; ++i) { + jsize length; + + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) buf, i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + writeBuf[i] = NULL; + continue; + } + + length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5AwriteVL_str: string not pinned"); + + if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_str: failed to allocate string buffer"); + + HDstrncpy(writeBuf[i], utf8, (size_t)length); + writeBuf[i][length] = '\0'; + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } /* end for (i = 0; i < size; ++i) */ + + if ((status = H5Awrite((hid_t)aid, (hid_t)tid, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + if (writeBuf) { for (i = 0; i < size; i++) { - if(wdata[i]) { - HDfree(wdata[i]); - } /* end if */ - } /* end for */ - HDfree(wdata); + if (writeBuf[i]) + HDfree(writeBuf[i]); + } - if (status < 0) - h5libraryError(env); - } /* end else */ + HDfree(writeBuf); + } return (jint)status; } -herr_t +/* + * Helper method to convert an array of Java strings into a buffer of + * variable-length (hvl_t) elements. The buffer of variable-length + * elements is then written to the HDF5 attribute. + */ +static herr_t H5AwriteVL_asstr (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) { - char **strs; - jstring jstr; - jint i; - jint n; - hid_t sid; - hsize_t dims[H5S_MAX_RANK]; - herr_t status = -1; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); - - if (strs == NULL) { - h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings"); - } /* end if */ - else { - status = H5Awrite(aid, tid, strs); - - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); - H5Sclose(sid); - HDfree(strs); - h5JNIFatalError(env, "H5AwriteVL_str: failed to read variable length strings"); - } /* end if */ - else { - for (i=0; i < n; i++) { - jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - H5free_memory (strs[i]); - } /* end for */ + const char *utf8 = NULL; + hsize_t dims[H5S_MAX_RANK]; + jstring jstr; + size_t typeSize; + size_t i; + hid_t sid = H5I_INVALID_HID; + jsize n; + void *writeBuf = NULL; + herr_t status = FAIL; + + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AwriteVL_asstr: buf length < 0"); + } + + dims[0] = (hsize_t)n; + if ((sid = H5Screate_simple(1, dims, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); + + /* + * When repeatedly writing a dataset with a large number of strs (e.g., 1,000,000 strings), + * H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings + * once done. + */ + for (i = 0; i < (size_t) n; i++) { + if (NULL == (jstr = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) buf, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); /* - for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, - H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect - free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings - after it is done. - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); - */ + * If the string object was NULL, skip it. + */ + HDmemset(&(((char *) writeBuf)[i * typeSize]), 0, typeSize); + continue; + } + + /* + * length = ENVPTR->GetStringUTFLength(ENVONLY, jstr); + * CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + */ + + PIN_JAVA_STRING(ENVONLY, jstr, utf8, NULL, "H5AwriteVL_asstr: failed to pin string buffer"); + + /* + * TODO: If the string isn't a copy, we should probably make + * one before destroying it with h5str_convert. + */ + + if (!h5str_convert(ENVONLY, (char **) &utf8, aid, tid, &(((char *) writeBuf)[i * typeSize]), 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - HDfree(strs); - } /* end else */ - } /* end else */ + UNPIN_JAVA_STRING(ENVONLY, jstr, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for (i = 0; i < n; i++) */ + + if ((status = H5Awrite(aid, tid, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, jstr, utf8); + if (writeBuf) { + H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, writeBuf); + HDfree(writeBuf); + } + if (sid >= 0) + H5Sclose(sid); return status; } /* end H5AwriteVL_str */ @@ -1316,47 +1374,52 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - herr_t status = -1; - h5str_t h5str; - size_t size; - hdset_reg_ref_t *ref_data; - jint i; - jint n; - jstring jstr; + hdset_reg_ref_t *ref_data = NULL; + h5str_t h5str; + jstring jstr; + jsize i, n; + herr_t status = FAIL; - hid_t region = -1; - hid_t aid = (hid_t) attr_id; - hid_t tid = (hid_t) mem_type_id; + UNUSED(clss); - n = ENVPTR->GetArrayLength(ENVPAR buf); - size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ - ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); + HDmemset(&h5str, 0, sizeof(h5str_t)); - if (ref_data == NULL) { - h5JNIFatalError(env, "H5Aread_reg_ref: failed to allocate buff for read"); - return -1; - } /* end if */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Aread_reg_ref: buf length < 0"); + } - status = H5Aread(aid, tid, ref_data); + if (NULL == (ref_data = (hdset_reg_ref_t *) HDmalloc((size_t)n * sizeof(hdset_reg_ref_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aread_reg_ref: failed to allocate read buffer"); - if (status < 0) { - HDfree(ref_data); - h5JNIFatalError(env, "H5Aread_reg_ref: failed to read data"); - return -1; - } /* end if */ + if ((status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, ref_data)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - HDmemset(&h5str, 0, sizeof(h5str_t)); h5str_new(&h5str, 1024); - for (i=0; iNewStringUTF(ENVPAR h5str.s); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)attr_id, (hid_t)mem_type_id, ref_data[i], 0, 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); } /* end for */ - h5str_free(&h5str); - HDfree(ref_data); +done: + if (h5str.s) + h5str_free(&h5str); + if (ref_data) + HDfree(ref_data); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref */ @@ -1370,12 +1433,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1space (JNIEnv *env, jclass clss, jlong attr_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Aget_space((hid_t)attr_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Aget_space((hid_t)attr_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aget_1space */ @@ -1388,12 +1453,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1type (JNIEnv *env, jclass clss, jlong attr_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Aget_type((hid_t)attr_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Aget_type((hid_t)attr_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aget_1type */ @@ -1406,34 +1473,29 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name (JNIEnv *env, jclass clss, jlong attr_id) { - char *aName; jstring str = NULL; ssize_t buf_size; + char *attrName = NULL; + + UNUSED(clss); + + if ((buf_size = H5Aget_name((hid_t)attr_id, 0, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name: failed to allocate attribute name buffer"); + + if (H5Aget_name((hid_t)attr_id, (size_t)buf_size + 1, attrName) < 0) + H5_LIBRARY_ERROR(ENVONLY); + attrName[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, attrName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (attrName) + HDfree(attrName); - /* get the length of the name */ - buf_size = H5Aget_name((hid_t)attr_id, 0, NULL); - if (buf_size <= 0) { - h5badArgument(env, "H5Aget_name: buf_size <= 0"); - } /* end if */ - else { - buf_size++; /* add extra space for the null terminator */ - aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (aName == NULL) { - h5outOfMemory(env, "H5Aget_name: malloc failed"); - } /* end if */ - else { - buf_size = H5Aget_name((hid_t)attr_id, (size_t)buf_size, aName); - if (buf_size < 0) { - HDfree(aName); - h5libraryError(env); - } /* end if */ - else { - /* save the string; */ - str = ENVPTR->NewStringUTF(ENVPAR aName); - HDfree(aName); - } /* end else */ - } /* end else */ - } /* end else */ return str; } /* end Java_hdf_hdf5lib_H5_H5Aget_1name */ @@ -1446,12 +1508,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs (JNIEnv *env, jclass clss, jlong loc_id) { - int retVal = -1; + int retVal = FAIL; + + UNUSED(clss); - retVal = H5Aget_num_attrs((hid_t)loc_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Aget_num_attrs((hid_t)loc_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Aget_1num_1attrs */ @@ -1464,18 +1528,19 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete (JNIEnv *env, jclass clss, jlong loc_id, jstring name) { - herr_t status = -1; - const char *aName; + const char *attrName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - status = H5Adelete((hid_t)loc_id, aName); + UNUSED(clss); - UNPIN_JAVA_STRING(name, aName); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Adelete: attribute name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Adelete((hid_t)loc_id, attrName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, name, attrName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Adelete */ @@ -1489,14 +1554,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Aclose (JNIEnv *env, jclass clss, jlong attr_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; - if (attr_id > 0) - retVal = H5Aclose((hid_t)attr_id); + UNUSED(clss); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Aclose((hid_t)attr_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aclose */ @@ -1510,24 +1575,24 @@ Java_hdf_hdf5lib_H5__1H5Acreate2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, jlong space_id, jlong create_plist, jlong access_plist) { - hid_t status = -1; - const char *aName; + const char *attrName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - status = H5Acreate2((hid_t)loc_id, aName, (hid_t)type_id, - (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, aName); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Acreate2: attribute name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, + (hid_t)space_id, (hid_t)create_plist, (hid_t)access_plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, name, attrName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Acreate2 */ - /* * Class: hdf_hdf5lib_H5 * Method: _H5Aopen @@ -1538,18 +1603,19 @@ Java_hdf_hdf5lib_H5__1H5Aopen (JNIEnv *env, jclass clss, jlong obj_id, jstring name, jlong access_plist) { - hid_t retVal = -1; - const char *aName; + const char *attrName = NULL; + hid_t retVal = H5I_INVALID_HID; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - retVal = H5Aopen((hid_t)obj_id, aName, (hid_t)access_plist); + UNUSED(clss); - UNPIN_JAVA_STRING(name, aName); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Aopen: attribute name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Aopen((hid_t)obj_id, attrName, (hid_t)access_plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, name, attrName); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aopen */ @@ -1563,19 +1629,20 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint idx_type, jint order, jlong n, jlong aapl_id, jlong lapl_id) { - hid_t retVal = -1; - const char *aName; + const char *objName = NULL; + hid_t retVal = H5I_INVALID_HID; - PIN_JAVA_STRING(name, aName); - if (aName != NULL) { - retVal = H5Aopen_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, - (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, aName); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aopen_by_idx: object name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Aopen_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, + (H5_iter_order_t)order, (hsize_t)n, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx */ @@ -1589,20 +1656,24 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong type_id, jlong space_id, jlong acpl_id, jlong aapl_id, jlong lapl_id) { - hid_t retVal = -1; - const char *aName; - const char *attrName; + const char *objName = NULL; + const char *attrName = NULL; + hid_t retVal = H5I_INVALID_HID; - PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); - if (aName != NULL && attrName != NULL) { - retVal = H5Acreate_by_name((hid_t)loc_id, aName, attrName, (hid_t)type_id, - (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Acreate_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Acreate_by_name: attribute name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Acreate_by_name((hid_t)loc_id, objName, attrName, (hid_t)type_id, + (hid_t)space_id, (hid_t)acpl_id, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name */ @@ -1616,21 +1687,25 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) { + const char *objName = NULL; + const char *attrName = NULL; htri_t bval = JNI_FALSE; - const char *aName; - const char *attrName; - PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); - if (aName != NULL && attrName != NULL) { - bval = H5Aexists_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aexists_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aexists_by_name: attribute name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5Aexists_by_name((hid_t)loc_id, objName, attrName, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Aexists_1by_1name */ @@ -1644,24 +1719,27 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename (JNIEnv *env, jclass clss, jlong loc_id, jstring old_attr_name, jstring new_attr_name) { - herr_t retVal = -1; - const char *oName; - const char *nName; + const char *oldAttrName = NULL; + const char *newAttrName = NULL; + herr_t retVal = FAIL; - PIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName); - if (oName != NULL && nName != NULL) { - retVal = H5Arename((hid_t)loc_id, oName, nName); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(old_attr_name, oName, new_attr_name, nName); + PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, "H5Arename: old attribute name not pinned"); + PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, "H5Arename: new attribute name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Arename((hid_t)loc_id, oldAttrName, newAttrName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (newAttrName) + UNPIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName); + if (oldAttrName) + UNPIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Arename */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Arename_by_name @@ -1671,20 +1749,27 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Arename_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring old_attr_name, jstring new_attr_name, jlong lapl_id) { - herr_t retVal = -1; - const char *aName; - const char *oName; - const char *nName; + const char *objName = NULL; + const char *oldAttrName = NULL; + const char *newAttrName = NULL; + herr_t retVal = FAIL; - PIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName); - if (aName != NULL && oName != NULL && nName != NULL) { - retVal = H5Arename_by_name((hid_t)loc_id, aName, oName, nName, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_THREE(obj_name, aName, old_attr_name, oName, new_attr_name, nName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Arename_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, "H5Arename_by_name: old attribute name not pinned"); + PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, "H5Arename_by_name: new attribute name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Arename_by_name((hid_t)loc_id, objName, oldAttrName, newAttrName, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (newAttrName) + UNPIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName); + if (oldAttrName) + UNPIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Arename_1by_1name */ @@ -1698,51 +1783,37 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) { - size_t buf_size; - char *aValue; - jlong status_size; - jstring str = NULL; - const char *aName; - - PIN_JAVA_STRING(obj_name, aName); - if (aName != NULL) { - /* get the length of the attribute name */ - status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, - (H5_iter_order_t) order, (hsize_t) n, (char*)NULL, (size_t)0, (hid_t)lapl_id); - - if(status_size < 0) { - UNPIN_JAVA_STRING(obj_name, aName); - h5libraryError(env); - } /* end if */ - else { - buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ - - aValue = (char*)HDmalloc(sizeof(char) * buf_size); - if (aValue == NULL) { - UNPIN_JAVA_STRING(obj_name, aName); - h5outOfMemory(env, "H5Aget_name_by_idx: malloc failed "); - } /* end if */ - else { - status_size = H5Aget_name_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, - (H5_iter_order_t) order, (hsize_t) n, (char*)aValue, (size_t)buf_size, (hid_t)lapl_id); - - UNPIN_JAVA_STRING(obj_name, aName); - - if (status_size < 0) { - HDfree(aValue); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aValue); - HDfree(aValue); - if (str == NULL) { - /* exception -- fatal JNI error */ - h5JNIFatalError(env, "H5Aget_name_by_idx: return string not created"); - } /* end if */ - } /* end else */ - } /* end else */ - } /* end else */ - } + const char *objName = NULL; + jstring str = NULL; + ssize_t status_size = -1; + char *attrName = NULL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_name_by_idx: object name not pinned"); + + /* Get the length of the attribute name */ + if ((status_size = H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, + (H5_iter_order_t) order, (hsize_t) n, (char *)NULL, (size_t)0, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (attrName = (char *) HDmalloc(sizeof(char) * (size_t) status_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Aget_name_by_idx: failed to allocate buffer for attribute name"); + + if ((H5Aget_name_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, + (H5_iter_order_t) order, (hsize_t) n, (char *)attrName, (size_t)status_size + 1, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + attrName[status_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, attrName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (attrName) + HDfree(attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); + return str; } /* end Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx */ @@ -1755,14 +1826,17 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Aget_1storage_1size (JNIEnv *env, jclass clss, jlong attr_id) { - hsize_t retVal = (hsize_t)-1; + hsize_t retVal = 0; - retVal = H5Aget_storage_size((hid_t)attr_id); -/* probably returns '0' if fails--don't do an exception */ + UNUSED(clss); + + if (!(retVal = H5Aget_storage_size((hid_t)attr_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Aget_1storage_1size */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Aget_info @@ -1772,23 +1846,23 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info (JNIEnv *env, jclass clss, jlong attr_id) { - herr_t status = -1; H5A_info_t ainfo; - jvalue args[4]; jobject ret_obj = NULL; + jvalue args[4]; - status = H5Aget_info((hid_t)attr_id, &ainfo); + UNUSED(clss); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].z = ainfo.corder_valid; - args[1].j = ainfo.corder; - args[2].i = ainfo.cset; - args[3].j = (jlong)ainfo.data_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); - } /* end else */ + if (H5Aget_info((hid_t)attr_id, &ainfo) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args, ret_obj); + +done: return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Aget_1info */ @@ -1801,30 +1875,31 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) { - herr_t status; + const char *objName = NULL; H5A_info_t ainfo; + herr_t status; jvalue args[4]; jobject ret_obj = NULL; - const char *aName; - PIN_JAVA_STRING(obj_name, aName); - if (aName != NULL) { - status = H5Aget_info_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, - (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING(obj_name, aName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_info_by_idx: object name not pinned"); + + if ((status = H5Aget_info_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, + (H5_iter_order_t)order, (hsize_t)n, &ainfo, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args, ret_obj); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].z = ainfo.corder_valid; - args[1].j = ainfo.corder; - args[2].i = ainfo.cset; - args[3].j = (jlong)ainfo.data_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); - } /* end else */ - } return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx */ @@ -1837,30 +1912,34 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) { - const char *aName; - const char *attrName; - herr_t status; + const char *objName = NULL; + const char *attrName = NULL; H5A_info_t ainfo; + herr_t status; jvalue args[4]; jobject ret_obj = NULL; - PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); - if (aName != NULL && attrName != NULL) { - status = H5Aget_info_by_name((hid_t)loc_id, aName, attrName, &ainfo, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_info_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aget_info_by_name: attribute name not pinned"); + + if ((status = H5Aget_info_by_name((hid_t)loc_id, objName, attrName, &ainfo, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].z = ainfo.corder_valid; + args[1].j = ainfo.corder; + args[2].i = ainfo.cset; + args[3].j = (jlong)ainfo.data_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args, ret_obj); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].z = ainfo.corder_valid; - args[1].j = ainfo.corder; - args[2].i = ainfo.cset; - args[3].j = (jlong)ainfo.data_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5A_info_t", "(ZJIJ)V", args); - } /* end else */ - } return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name */ @@ -1873,19 +1952,23 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong lapl_id) { - herr_t retVal = -1; - const char *aName; - const char *attrName; + const char *objName = NULL; + const char *attrName = NULL; + herr_t retVal = FAIL; - PIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); - if (aName != NULL && attrName != NULL) { - retVal = H5Adelete_by_name((hid_t)loc_id, aName, attrName, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(obj_name, aName, attr_name, attrName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Adelete_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Adelete_by_name: attribute name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Adelete_by_name((hid_t)loc_id, objName, attrName, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1name */ @@ -1899,20 +1982,21 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Aexists (JNIEnv *env, jclass clss, jlong obj_id, jstring attr_name) { + const char *attrName = NULL; htri_t bval = JNI_FALSE; - const char *aName; - PIN_JAVA_STRING(attr_name, aName); - if (aName != NULL) { - bval = H5Aexists((hid_t)obj_id, aName); + UNUSED(clss); - UNPIN_JAVA_STRING(attr_name, aName); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aexists: attribute name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5Aexists((hid_t)obj_id, attrName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Aexists */ @@ -1926,18 +2010,19 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jint idx_type, jint order, jlong n, jlong lapl_id) { - herr_t status = -1; - const char *aName; + const char *objName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(obj_name, aName); - if (aName != NULL) { - status = H5Adelete_by_idx((hid_t)loc_id, aName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING(obj_name, aName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Adelete_by_idx: object name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Adelete_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); } /* end Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx */ /* @@ -1950,19 +2035,23 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring obj_name, jstring attr_name, jlong aapl_id, jlong lapl_id) { - hid_t status = -1; - const char *aName; - const char *oName; + const char *attrName = NULL; + const char *objName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName); - if (oName != NULL && aName != NULL) { - status = H5Aopen_by_name((hid_t)loc_id, oName, aName, (hid_t)aapl_id, (hid_t)lapl_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(obj_name, oName, attr_name, aName); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aopen_by_name: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aopen_by_name: attribute name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Aopen_by_name((hid_t)loc_id, objName, attrName, (hid_t)aapl_id, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (attrName) + UNPIN_JAVA_STRING(ENVONLY, attr_name, attrName); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, obj_name, objName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name */ @@ -1976,60 +2065,69 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist (JNIEnv *env, jclass clss, jlong attr_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Aget_create_plist((hid_t)attr_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Aget_create_plist((hid_t)attr_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Aget_1create_1plist */ static herr_t H5A_iterate_cb (hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data) { - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - jmethodID constructor; - jvalue args[4]; - jobject cb_info_t = NULL; cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - - args[0].z = info->corder_valid; - args[1].j = info->corder; - args[2].i = info->cset; - args[3].j = (jlong)info->data_size; - /* get a reference to your class if you don't have it already */ - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5A_info_t"); - if (cls != 0) { - /* get a reference to the constructor; the name is */ - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(ZJIJ)V"); - if (constructor != 0) { - cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (cb_info_t == NULL) { - printf("FATAL ERROR: hdf/hdf5lib/structs/H5A_info_t: Creation failed\n"); - } - else { - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); - } - } /* end if (constructor != 0) */ - } /* end if (cls != 0) */ - } /* end if (mid != 0) */ - } /* end if (cls != 0) */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); + jmethodID constructor, mid; + jobject cb_info_t = NULL; + jobject visit_callback = wrapper->visit_callback; + jstring str; + JNIEnv *cbenv = NULL; + jclass cls; + jvalue args[4]; + void *op_data = (void *)wrapper->op_data; + jint status = -1; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5A_iterate_cb: failed to attach current thread to JVM"); + } + + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[0].z = info->corder_valid; + args[1].j = info->corder; + args[2].i = info->cset; + args[3].j = (jlong)info->data_size; + + /* Get a reference to your class if you don't have it already */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5A_info_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* Get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(ZJIJ)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5A_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); return (herr_t)status; } /* end H5A_iterate_cb */ @@ -2044,22 +2142,24 @@ Java_hdf_hdf5lib_H5_H5Aiterate (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jlong idx, jobject callback_op, jobject op_data) { - hsize_t start_idx = (hsize_t)idx; - herr_t status = -1; + cb_wrapper wrapper = { callback_op, op_data }; + hsize_t start_idx = (hsize_t)idx; + herr_t status = FAIL; - cb_wrapper wrapper = {callback_op, op_data}; - ENVPTR->GetJavaVM(ENVPAR &jvm); + UNUSED(clss); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); - } /* end if */ - else { - status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (status < 0) - h5libraryError(env); - } /* end else */ + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate: callback_op is NULL"); + if ((status = H5Aiterate2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aiterate */ @@ -2073,27 +2173,29 @@ Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, jlong idx, jobject callback_op, jobject op_data, jlong access_id) { - const char *lName; - hsize_t start_idx = (hsize_t)idx; - herr_t status = -1; - cb_wrapper wrapper = {callback_op, op_data}; + const char *objName = NULL; + cb_wrapper wrapper = { callback_op, op_data }; + hsize_t start_idx = (hsize_t)idx; + herr_t status = FAIL; - ENVPTR->GetJavaVM(ENVPAR &jvm); + UNUSED(clss); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Aiterate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper, (hid_t)access_id); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - UNPIN_JAVA_STRING(name, lName); + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate_by_name: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate_by_name: callback_op is NULL"); - if (status < 0) - h5libraryError(env); - } - } /* end else */ + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aiterate_by_name: object name not pinned"); + + if ((status = H5Aiterate_by_name((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5A_operator2_t)H5A_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name */ diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 79a5d0a..0ed3b6e 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -27,8 +27,12 @@ extern "C" { #include #include "hdf5.h" #include "h5util.h" +#include "h5jni.h" #include "h5dImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; typedef struct _cb_wrapper { @@ -36,121 +40,19 @@ typedef struct _cb_wrapper { jobject op_data; } cb_wrapper; -#ifdef __cplusplus - #ifdef _WINDOWS - #include - #endif - #define CBENVPTR (cbenv) - #define CBENVPAR - #define JVMPTR (jvm) - #define JVMPAR - #define JVMPAR2 -#else - #define CBENVPTR (*cbenv) - #define CBENVPAR cbenv, - #define JVMPTR (*jvm) - #define JVMPAR jvm - #define JVMPAR2 jvm, -#endif - /********************/ /* Local Prototypes */ /********************/ -static herr_t H5DreadVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DreadVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DreadVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DwriteVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DwriteVL_str (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); -static herr_t H5DwriteVL_array (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DreadVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DreadVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_asstr(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); +static herr_t H5DwriteVL_str(JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf); /********************/ /* Local Macros */ /********************/ -#define PIN_BYTE_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_BYTE_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_SHORT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_SHORT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_INT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_INT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_LONG_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \ -} - -#define UNPIN_LONG_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_FLOAT_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_FLOAT_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \ -} - -#define PIN_DOUBLE_ARRAY() { \ - if (isCriticalPinning) \ - buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ - else \ - buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \ -} - -#define UNPIN_DOUBLE_ARRAY(mode) { \ - if (isCriticalPinning) \ - ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ - else \ - ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \ -} /* * Class: hdf_hdf5lib_H5 @@ -162,18 +64,19 @@ Java_hdf_hdf5lib_H5__1H5Dcreate (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, jlong space_id, jlong create_plist_id) { - hid_t dset_id = -1; - const char *fileName; + const char *dsetName = NULL; + hid_t dset_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate: dataset name not pinned"); - if (dset_id < 0) - h5libraryError(env); - } + if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dsetName) + UNPIN_JAVA_STRING(ENVONLY, name, dsetName); return (jlong)dset_id; } /* end Java_hdf_hdf5lib_H5__1H5Dcreate */ @@ -187,17 +90,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen (JNIEnv *env, jclass clss, jlong loc_id, jstring name) { - hid_t dset_id = -1; - const char *fileName; + const char *dsetName = NULL; + hid_t dset_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - dset_id = H5Dopen2((hid_t)loc_id, fileName, H5P_DEFAULT); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); - if (dset_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dopen: dataset name not pinned"); + + if ((dset_id = H5Dopen2((hid_t)loc_id, dsetName, H5P_DEFAULT))) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dsetName) + UNPIN_JAVA_STRING(ENVONLY, name, dsetName); return (jlong)dset_id; } /* end Java_hdf_hdf5lib_H5__1H5Dopen */ @@ -211,12 +116,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1space (JNIEnv *env, jclass clss, jlong dataset_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Dget_space((hid_t)dataset_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Dget_space((hid_t)dataset_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Dget_1space */ @@ -229,12 +136,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1type (JNIEnv *env, jclass clss, jlong dataset_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Dget_type((hid_t)dataset_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Dget_type((hid_t)dataset_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Dget_1type */ @@ -247,40 +156,17 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist (JNIEnv *env, jclass clss, jlong dataset_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Dget_create_plist((hid_t)dataset_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Dget_create_plist((hid_t)dataset_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Dget_1create_1plist */ -static htri_t -H5Tdetect_variable_str - (hid_t tid) { - htri_t ret_val = 0; - - if (H5Tget_class(tid) == H5T_COMPOUND) { - unsigned i; - unsigned nm = (unsigned)H5Tget_nmembers(tid); - for(i = 0; i < nm; i++) { - htri_t status = 0; - hid_t mtid = 0; - if((mtid = H5Tget_member_type(tid, i)) < 0) - return -1; /* exit immediately on error */ - if((status = H5Tdetect_variable_str(mtid)) < 0) - return status; /* exit immediately on error */ - ret_val |= status; - H5Tclose (mtid); - } /* end for */ - } /* end if */ - else - ret_val = H5Tis_variable_str(tid); - - return ret_val; -} /* end H5Tdetect_variable_str */ - /* * Class: hdf_hdf5lib_H5 * Method: H5Dread @@ -291,48 +177,49 @@ Java_hdf_hdf5lib_H5_H5Dread (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jbyte *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + htri_t data_class; + jbyte *readBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread: variable length type not supported"); + + if (isCriticalPinning) { + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread: buf does not support variable length type"); - } /* end else if */ + PIN_BYTE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_BYTE_ARRAY(); - - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_BYTE_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_BYTE_ARRAY(0); /* update java buffer for return */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_BYTE_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread */ @@ -347,44 +234,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jbyteArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jbyte *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + htri_t data_class; + jbyte *writeBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite: variable length type not supported"); + + if (isCriticalPinning) { + PIN_BYTE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite: buf does not support variable length type"); - } /* end else if */ + PIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_BYTE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */ - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_BYTE_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite */ @@ -398,13 +290,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Dclose (JNIEnv *env, jclass clss, jlong dataset_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Dclose((hid_t)dataset_id); + UNUSED(clss); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Dclose((hid_t)dataset_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Dclose */ @@ -417,15 +310,17 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1storage_1size (JNIEnv *env, jclass clss, jlong dataset_id) { - hsize_t retVal = (hsize_t)-1; + hsize_t retVal = 0; - if (dataset_id < 0) { - h5badArgument(env, "H5Dget_storage_size: not a dataset"); - } /* end if */ - else { - retVal = H5Dget_storage_size((hid_t)dataset_id); - } /* end else */ + UNUSED(clss); + + if (dataset_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dget_storage_size: not a dataset"); + if (!(retVal = H5Dget_storage_size((hid_t)dataset_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Dget_1storage_1size */ @@ -439,27 +334,23 @@ Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim (JNIEnv *env, jclass clss, jlong type_id, jlong space_id, jlong xfer_plist_id, jbyteArray buf) { - herr_t status = -1; - jbyte *byteP; - jboolean isCopy; + jboolean vlenBufIsCopy; + jbyte *vlenBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dvlen_reclaim: buf is NULL"); - } /* end if */ - else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Dvlen_reclaim: buf not pinned"); - } /* end if */ - else { - status = H5Dvlen_reclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, byteP); + UNUSED(clss); - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dvlen_reclaim: buffer is NULL"); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + PIN_BYTE_ARRAY(ENVONLY, buf, vlenBuf, &vlenBufIsCopy, "H5Dvlen_reclaim: buffer not pinned"); + + if ((status = H5Dvlen_reclaim((hid_t)type_id, (hid_t)space_id, (hid_t)xfer_plist_id, vlenBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (vlenBuf) + UNPIN_BYTE_ARRAY(ENVONLY, buf, vlenBuf, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dvlen_1reclaim */ @@ -474,47 +365,49 @@ Java_hdf_hdf5lib_H5_H5Dread_1short (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jshort *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + jshort *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_short: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_short: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_short: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_short: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_short: variable length type not supported"); + + if (isCriticalPinning) { + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_short: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread_short: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_short: buf does not support variable length type"); - } /* end else if */ + PIN_SHORT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_short: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_SHORT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread_short: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_SHORT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_SHORT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_SHORT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1short */ @@ -529,44 +422,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1short (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jshortArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jshort *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + jshort *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; - if (buf == NULL ) { - h5nullArgument(env, "H5Dwrite_short: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_short: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_short: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_short: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_short: variable length type not supported"); + + if (isCriticalPinning) { + PIN_SHORT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_short: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite_short: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_short: buf does not support variable length type"); - } /* end else if */ + PIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_short: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_SHORT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite_short: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_SHORT_ARRAY(JNI_ABORT); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_SHORT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1short */ @@ -581,47 +479,49 @@ Java_hdf_hdf5lib_H5_H5Dread_1int (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jint *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + htri_t data_class; + jint *readBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_int: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread_int: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_int: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_int: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_int: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_int: variable length type not supported"); + + if (isCriticalPinning) { + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_int: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread_int: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_int: buf does not support variable length type"); - } /* end else if */ + PIN_INT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_int: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_INT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread_int: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_INT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_INT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_INT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1int */ @@ -636,44 +536,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1int (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jintArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jint *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + htri_t data_class; + jint *writeBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite_int: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_int: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_int: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_int: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_int: variable length type not supported"); + + if (isCriticalPinning) { + PIN_INT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_int: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite_int: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_int: buf does not support variable length type"); - } /* end else if */ + PIN_INT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_int: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_INT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite_int: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_INT_ARRAY(JNI_ABORT); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_INT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1int */ @@ -688,47 +593,49 @@ Java_hdf_hdf5lib_H5_H5Dread_1long (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jlong *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + htri_t data_class; + jlong *readBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_long: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread_long: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_long: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_long: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_long: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_long: variable length type not supported"); + + if (isCriticalPinning) { + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_long: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread_long: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_long: buf does not support variable length type"); - } /* end else if */ + PIN_LONG_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_long: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_LONG_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread_long: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_LONG_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_LONG_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_LONG_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1long */ @@ -743,43 +650,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1long (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jlongArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jlong *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + htri_t data_class; + jlong *writeBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite_long: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_long: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_long: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_long: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_long: variable length type not supported"); + + if (isCriticalPinning) { + PIN_LONG_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_long: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_long: buf does not support variable length type"); - } /* end else if */ + PIN_LONG_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_long: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_LONG_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite_long: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_LONG_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_LONG_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1long */ @@ -794,47 +707,49 @@ Java_hdf_hdf5lib_H5_H5Dread_1float (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jfloat *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + htri_t data_class; + jfloat *readBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_float: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_float: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_float: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_float: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_float: variable length type not supported"); + + if (isCriticalPinning) { + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_float: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread_float: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_float: buf does not support variable length type"); - } /* end else if */ + PIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_float: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_FLOAT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread_float: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_FLOAT_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_FLOAT_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_FLOAT_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1float */ @@ -849,43 +764,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1float (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jfloatArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jfloat *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + htri_t data_class; + jfloat *writeBuf = NULL; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite_float: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_float: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_float: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_float: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_float: variable length type not supported"); + + if (isCriticalPinning) { + PIN_FLOAT_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_float: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite_float: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_float: buf does not support variable length type"); - } /* end else if */ + PIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_float: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_FLOAT_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite_float: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_FLOAT_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_FLOAT_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1float */ @@ -900,47 +821,49 @@ Java_hdf_hdf5lib_H5_H5Dread_1double (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jdouble *buffP; - jboolean isCopy; - htri_t data_class; + jboolean readBufIsCopy; + jdouble *readBuf = NULL; + htri_t data_class; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_double: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dread_double: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_double: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_double: read buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_double: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_double: variable length type not supported"); + + if (isCriticalPinning) { + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_double: read buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dread_double: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dread_double: buf does not support variable length type"); - } /* end else if */ + PIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, &readBufIsCopy, "H5Dread_double: read buffer not pinned"); + } + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (readBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_DOUBLE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dread_double: buf not pinned"); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - if (status < 0) { - UNPIN_DOUBLE_ARRAY(JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - UNPIN_DOUBLE_ARRAY(0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_DOUBLE_ARRAY(ENVONLY, buf, readBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1double */ @@ -955,43 +878,49 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1double (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jdoubleArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - jdouble *buffP; - jboolean isCopy; - htri_t data_class; + jboolean writeBufIsCopy; + jdouble *writeBuf = NULL; + htri_t data_class; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite_double: buf is NULL"); - } /* end if */ - else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { - h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_class() failed"); - } /* end else if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_double: buf does not support variable length type"); - } /* end else if */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_double: write buffer is NULL"); + + if ((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_double: variable length type not supported"); + + /* Recursively detect any vlen string in type (compound, array ...) */ + if ((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (data_class) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_double: variable length type not supported"); + + if (isCriticalPinning) { + PIN_DOUBLE_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_double: write buffer not critically pinned"); + } else { - /* recursive detect any vlen string in type (compound, array ...) */ - if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { - h5JNIFatalError(env, "H5Dwrite_double: H5Tdetect_variable_str() failed"); - } /* end if */ - else if(data_class == 1) { - h5badArgument(env, "H5Dwrite_double: buf does not support variable length type"); - } /* end else if */ + PIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, &writeBufIsCopy, "H5Dwrite_double: write buffer not pinned"); + } + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (writeBuf) { + if (isCriticalPinning) { + UNPIN_ARRAY_CRITICAL(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } else { - PIN_DOUBLE_ARRAY(); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dwrite_double: buf not pinned"); - } /* end if */ - else { - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, buffP); - - UNPIN_DOUBLE_ARRAY(JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + UNPIN_DOUBLE_ARRAY(ENVONLY, buf, writeBuf, (status < 0) ? JNI_ABORT : 0); + } + } return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1double */ @@ -1006,68 +935,59 @@ Java_hdf_hdf5lib_H5_H5Dread_1string (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) { - herr_t status = -1; - char *c_buf; - char *cstr; - size_t str_len; - jsize i; - jsize n; - size_t pos; - jstring jstr; - - c_buf = cstr = NULL; - if (j_buf == NULL) { - h5nullArgument(env, "H5Dread_string: buf is NULL"); - } /* end if */ - else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { - h5nullArgument(env, "H5Dread_string: buf length <= 0"); - } /* end else if */ - else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) { - h5libraryError(env); - } /* end else if */ - else { - if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) { - h5JNIFatalError(env, "H5Dread_string: memory allocation failed."); - } /* end if */ - else { - if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) { - if (cstr) - HDfree(cstr); - cstr = NULL; - h5JNIFatalError(env, "H5Dread_string: memory allocation failed."); - } /* end if */ - else { - status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf); - - if (status < 0) { - if (cstr) - HDfree(cstr); - cstr = NULL; - if (c_buf) - HDfree(c_buf); - c_buf = NULL; - h5libraryError(env); - } /* end if */ - else { - pos = 0; - for (i = 0; i < n; i++) { - HDmemcpy(cstr, c_buf+pos, str_len); - cstr[str_len] = '\0'; - jstr = ENVPTR->NewStringUTF(ENVPAR cstr); - ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr); - pos += str_len; - } /* end for */ - } /* end else */ - - if (c_buf) - HDfree(c_buf); - } /* end else cbuf allocation*/ - - if (cstr) - HDfree(cstr); - } /* end else cstr allocation*/ - } /* end else */ + jstring jstr; + size_t str_len; + size_t pos; + jsize i, n; + char *c_buf = NULL; + char *cstr = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == j_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_string: read buffer is NULL"); + + if ((n = ENVPTR->GetArrayLength(ENVONLY, j_buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_string: read buffer length <= 0"); + } + + if (!(str_len = H5Tget_size((hid_t)mem_type_id))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (cstr = (char *) HDmalloc(str_len + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + + if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: memory allocation failed"); + + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0, pos = 0; i < n; i++) { + HDmemcpy(cstr, c_buf+pos, str_len); + cstr[str_len] = '\0'; + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, cstr))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_string: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, j_buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + pos += str_len; + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (c_buf) + HDfree(c_buf); + if (cstr) + HDfree(cstr); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1string */ @@ -1082,53 +1002,64 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray j_buf) { - herr_t status = -1; - char *c_buf; - jsize str_len; - jsize i; - jsize n; - - if (j_buf == NULL) { - h5nullArgument(env, "H5Dwrite_string: buf is NULL"); - } /* end if */ - else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { - h5nullArgument(env, "H5Dwrite_string: buf length <= 0"); - } /* end else if */ - else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) { - h5libraryError(env); - } /* end else if */ - else { - if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) { - h5JNIFatalError(env, "H5Dwrite_string: memory allocation failed."); - } /* end if */ - else { - for (i = 0; i < n; i++) { - jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); - - if (utf8) { - HDstrncpy(&c_buf[i * str_len], utf8, str_len); - } /* end if */ - - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for */ - - status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, - (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf); - - if (c_buf) - HDfree(c_buf); - c_buf = NULL; - - if (status < 0) { - h5libraryError(env); - } /* end if */ - } /* end else */ - } /* end else */ + const char *utf8 = NULL; + jstring obj; + size_t i, str_len; + jsize n; + char *c_buf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == j_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_string: write buffer is NULL"); + + if ((n = ENVPTR->GetArrayLength(ENVONLY, j_buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_string: write buffer length <= 0"); + } + + if (!(str_len = H5Tget_size((hid_t)mem_type_id))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (c_buf = (char *) HDmalloc((size_t)n * str_len))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dwrite_string: memory allocation failed"); + + for (i = 0; i < (size_t) n; i++) { + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)j_buf, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + HDmemset(&c_buf[i * str_len], 0, str_len); + continue; + } + + /* + * length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + * CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + */ + + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5Dwrite_string: string not pinned"); + + HDstrncpy(&c_buf[i * str_len], utf8, str_len); + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } /* end for */ + + if ((status = H5Dwrite((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, + (hid_t)file_space_id, (hid_t)xfer_plist_id, c_buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + if (c_buf) + HDfree(c_buf); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1string */ @@ -1143,106 +1074,216 @@ Java_hdf_hdf5lib_H5_H5DreadVL (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + H5T_class_t type_class; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; + htri_t isComplex2 = 0; + hid_t nested_tid = H5I_INVALID_HID; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5DreadVL: buf is NULL"); - } /* end if */ - else { - isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { - unsigned i; - int nm = H5Tget_nmembers(mem_type_id); - for(i = 0; i 0 || isVlenStr) { - status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); - } - else if (isStr > 0) { - status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5DreadVL: read buffer is NULL"); + + if ((isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (type_class == H5T_COMPOUND) { + unsigned i; + int num_members; + + if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (unsigned) num_members; i++) { + if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + isComplex = isComplex || isComplex2; + + if (H5Tclose(nested_tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nested_tid = H5I_INVALID_HID; } - } /* end else */ + } + else if (type_class == H5T_VLEN) { + isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ + } + + if (!isStr || isComplex || isVlenStr) { + if ((status = H5DreadVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else if (isStr) { + if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (nested_tid >= 0) + H5Tclose(nested_tid); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */ -herr_t +/* + * Helper method to read in a buffer of variable-length strings from an HDF5 + * dataset. Each C-string is converted to a Java string and set in the output + * buffer in turn. + */ +static herr_t +H5DreadVL_str + (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) +{ + jstring jstr; + jsize i, n; + char **strs = NULL; + herr_t status = FAIL; + + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DreadVL_str: buf length < 0"); + } + + if (NULL == (strs = (char **) HDcalloc((size_t)n, sizeof(char *)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_str: failed to allocate variable length string read buffer"); + + if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* + * When repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings), + * H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + * free space in time. Instead, we use "H5free_memory(strs[i])" to free individual strings + * once done. + */ + for (i = 0; i < n; i++) { + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, strs[i]))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + H5free_memory(strs[i]); + strs[i] = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (strs) { + for (i = 0; i < n; i++) { + if (strs[i]) + H5free_memory(strs[i]); + } + + HDfree(strs); + } + + return status; +} /* end H5DreadVL_str */ + +/* + * Helper method to read in a buffer of variable-length (hvl_t) + * structures from an HDF5 dataset and convert each variable-length + * element's buffer into a Java string. Each string is then set + * in the output buffer in turn. + */ +static herr_t H5DreadVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) { - jint i; - jint n; - jstring jstr; - h5str_t h5str; - hvl_t *rdata; - size_t size; - size_t max_len = 0; - herr_t status = -1; + H5T_class_t tclass; + jstring jstr; + h5str_t h5str; + hbool_t close_mem_space = FALSE; + size_t typeSize; + size_t i; + hid_t mem_space = mem_sid; + jsize n; + void *readBuf = NULL; + herr_t status = FAIL; + + HDmemset(&h5str, 0, sizeof(h5str_t)); + + if (mem_space == H5S_ALL) { + mem_space = file_sid; + + if (mem_space == H5S_ALL) { + /* + * Retrieve a valid dataspace for H5Dvlen_reclaim(). + */ + if ((mem_space = H5Dget_space(did)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + close_mem_space = TRUE; + + if (H5Sselect_all(mem_space) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + } /* Get size of string array */ - n = ENVPTR->GetArrayLength(ENVPAR buf); - /* we will need to read n number of hvl_t structures */ - rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); - if (rdata == NULL) { - h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buff for read"); - } /* end if */ - else { - status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata); + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DreadVL_asstr: buf length < 0"); + } - if (status < 0) { - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata); - HDfree(rdata); - h5JNIFatalError(env, "H5DreadVL_asstr: failed to read data"); - } /* end if */ - else { - /* calculate the largest size of all the hvl_t structures read */ - max_len = 1; - for (i=0; i < n; i++) { - if ((rdata + i)->len > max_len) - max_len = (rdata + i)->len; - } - - /* create one malloc to hold largest element */ - size = H5Tget_size(tid) * max_len; - HDmemset(&h5str, 0, sizeof(h5str_t)); - h5str_new(&h5str, 4 * size); - - if (h5str.s == NULL) { - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata); - HDfree(rdata); - h5JNIFatalError(env, "H5DreadVL_asstr: failed to allocate buf"); - } /* end if */ - else { - H5T_class_t tclass = H5Tget_class(tid); - /* convert each element to char string */ - for (i=0; i < n; i++) { - h5str.s[0] = '\0'; - h5str_vlsprintf(&h5str, did, tid, rdata+i, 0); - jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - } /* end for */ - h5str_free(&h5str); - - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata); - HDfree(rdata); - } /* end else */ - } /* end else */ - } /* end else */ + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (readBuf = HDcalloc((size_t)n, typeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate read buffer"); + + if ((status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Allocate a decent-sized initial string */ + h5str_new(&h5str, 4 * typeSize); + + if (!h5str.s) + H5_JNI_FATAL_ERROR(ENVONLY, "H5DreadVL_asstr: failed to allocate buffer"); + + if ((tclass = H5Tget_class(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Convert each element to a char string */ + for (i = 0; i < (size_t) n; i++) { + h5str.s[0] = '\0'; + + if (!h5str_sprintf(ENVONLY, &h5str, did, tid, &(((char *) readBuf)[i * typeSize]), typeSize, 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (h5str.s) + h5str_free(&h5str); + if (readBuf) { + H5Dvlen_reclaim(tid, mem_space, xfer_plist_id, readBuf); + HDfree(readBuf); + } + if (close_mem_space) + H5Sclose(mem_space); return status; } @@ -1264,168 +1305,265 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - htri_t isVlenStr=0; + htri_t isVlenStr = 0; + herr_t status = FAIL; - if (buf == NULL) { - h5nullArgument(env, "H5Dread_VLStrings: buf is NULL"); - } /* end if */ - else { - isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); + UNUSED(clss); - if (isVlenStr) { - status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); - } /* end if */ - else - h5badArgument(env, "H5Dread_VLStrings: type is not variable length String"); - } /* end else */ + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dread_VLStrings: read buffer is NULL"); + if ((isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (isVlenStr) { + if ((status = H5DreadVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + else + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_VLStrings: datatype is not variable length String"); + +done: return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1VLStrings */ -herr_t -H5DreadVL_str - (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) +/* + * Class: hdf_hdf5lib_H5 + * Method: H5DwriteVL + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5DwriteVL + (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, + jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - char **strs; - jstring jstr; - jint i; - jint n; - herr_t status = -1; + H5T_class_t type_class; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; + htri_t isComplex2 = 0; + hid_t nested_tid = H5I_INVALID_HID; + herr_t status = FAIL; - n = ENVPTR->GetArrayLength(ENVPAR buf); - strs =(char**)HDcalloc((size_t)n, sizeof(char*)); + UNUSED(clss); - if (strs == NULL) { - h5JNIFatalError(env, "H5DreadVL_str: failed to allocate buff for read variable length strings"); - } /* end if */ - else { - status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, strs); + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5DwriteVL: write buffer is NULL"); - if (status < 0) { - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); - HDfree(strs); - h5JNIFatalError(env, "H5DreadVL_str: failed to read variable length strings"); - } /* end if */ - else { - for (i=0; i < n; i++) { - jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - H5free_memory (strs[i]); - } /* end for */ + if ((isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - /* - for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, - H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect - free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings - after it is done. - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); - */ + if ((type_class = H5Tget_class((hid_t)mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - HDfree(strs); - } /* end else */ - } /* end else */ + if (type_class == H5T_COMPOUND) { + unsigned i; + int num_members; - return status; -} /* end H5DreadVL_str */ + if ((num_members = H5Tget_nmembers(mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (unsigned) num_members; i++) { + if ((nested_tid = H5Tget_member_type((hid_t)mem_type_id, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((isComplex2 = H5Tdetect_class((hid_t)nested_tid, H5T_VLEN)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + isComplex = isComplex || isComplex2; + + if (H5Tclose(nested_tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nested_tid = H5I_INVALID_HID; + } + } + else if (type_class == H5T_VLEN) { + isVlenStr = 1; /* Strings created by H5Tvlen_create(H5T_C_S1) */ + } + + if (!isStr || isComplex || isVlenStr) { + if ((status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else if (isStr) { + if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (nested_tid >= 0) + H5Tclose(nested_tid); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */ /* - * Class: hdf_hdf5lib_H5 - * Method: H5DwriteVL - * Signature: (JJJJJ[Ljava/lang/String;)I + * Helper method to convert an array of Java strings into a buffer of C-strings. + * The buffer of C-strings is then written to the HDF5 dataset specified. */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5DwriteVL - (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) +static herr_t +H5DwriteVL_str + (JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + const char *utf8 = NULL; + jstring obj; + jsize size; + jsize i; + char **writeBuf = NULL; + herr_t status = FAIL; + + if ((size = ENVPTR->GetArrayLength(ENVONLY, (jarray) buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DwriteVL_str: buf length < 0"); + } - if (buf == NULL) { - h5nullArgument(env, "H5DwriteVL: buf is NULL"); - } /* end if */ - else { - isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { - unsigned i; - int nm = H5Tget_nmembers(mem_type_id); - for(i = 0; i 0 || isVlenStr) { - status = H5DwriteVL_asstr(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); + if (NULL == (writeBuf = (char **) HDcalloc((size_t)size + 1, sizeof(char *)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate variable length string write buffer"); + + for (i = 0; i < size; ++i) { + jsize length; + + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + writeBuf[i] = NULL; + continue; } - else if (isStr > 0) { - status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); + + length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5DwriteVL_str: string not pinned"); + + if (NULL == (writeBuf[i] = (char *) HDmalloc((size_t)length + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5DwriteVL_str: failed to allocate string buffer"); + + HDstrncpy(writeBuf[i], utf8, (size_t)length + 1); + writeBuf[i][length] = '\0'; + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } /* end for (i = 0; i < size; ++i) */ + + if ((status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + if (writeBuf) { + for (i = 0; i < size; i++) { + if (writeBuf[i]) + HDfree(writeBuf[i]); } - } /* end else */ - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */ + HDfree(writeBuf); + } + + return status; +} /* end H5DwriteVL_str */ -herr_t +/* + * Helper method to convert an array of Java strings into a buffer of + * variable-length (hvl_t) elements. The buffer of variable-length + * elements is then written to the HDF5 dataset. + */ +static herr_t H5DwriteVL_asstr (JNIEnv *env, hid_t did, hid_t tid, hid_t mem_sid, hid_t file_sid, hid_t xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - hvl_t *wdata; - jsize size; - jint i; - jint n; + const char *utf8 = NULL; + jstring obj; + hbool_t close_mem_space = FALSE; + size_t typeSize; + size_t i; + hid_t mem_space = mem_sid; + jsize n; + void *writeBuf = NULL; + herr_t status = FAIL; + + if (mem_space == H5S_ALL) { + mem_space = file_sid; + + if (mem_space == H5S_ALL) { + /* + * Retrieve a valid dataspace for H5Dvlen_reclaim(). + */ + if ((mem_space = H5Dget_space(did)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + close_mem_space = TRUE; + + if (H5Sselect_all(mem_space) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + } - /* Get size of string array */ - n = ENVPTR->GetArrayLength(ENVPAR buf); - wdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5DwriteVL_asstr: buf length < 0"); + } - if (wdata == NULL) { - h5JNIFatalError(env, "H5DwriteVL_asstr: failed to allocate buff for write"); - } /* end if */ - else { - for (i = 0; i < n; ++i) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); - if (utf8) { - h5str_vlconvert(utf8, did, tid, wdata+i, 0); - } /* end if */ + if (NULL == (writeBuf = HDcalloc((size_t)n, typeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AwriteVL_asstr: failed to allocate write buffer"); - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for (i = 0; i < size; ++i) */ + for (i = 0; i < (size_t) n; ++i) { + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray)buf, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, wdata); + /* + * If the string object was NULL, skip it. + */ + HDmemset(&(((char *) writeBuf)[i * typeSize]), 0, typeSize); + continue; + } - /* now free memory*/ - for (i = 0; i < n; i++) { - if(wdata+i) { - HDfree(wdata+i); - } /* end if */ - } /* end for */ - HDfree(wdata); + /* + * length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + * CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + */ - if (status < 0) - h5libraryError(env); - } /* end else */ + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5DwriteVL_asstr: failed to pin string buffer"); + + /* + * TODO: If the string isn't a copy, we should probably make + * one before destroying it with h5str_convert. + */ + + if (!h5str_convert(ENVONLY, (char **) &utf8, did, tid, &(((char *) writeBuf)[i * typeSize]), 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } /* end for (i = 0; i < size; ++i) */ + + if ((status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, writeBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + if (writeBuf) { + H5Dvlen_reclaim(tid, mem_space, xfer_plist_id, writeBuf); + HDfree(writeBuf); + } + if (close_mem_space) + H5Sclose(mem_space); return status; } /* end H5DwriteVL_asstr */ @@ -1440,79 +1578,28 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings (JNIEnv *env, jclass clss, jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - htri_t isVlenStr=0; - - if (buf == NULL) { - h5nullArgument(env, "H5Dwrite_VLStrings: buf is NULL"); - } /* end if */ - else { - isVlenStr = H5Tis_variable_str((hid_t)mem_type_id); + htri_t isVlenStr = 0; + herr_t status = FAIL; - if (isVlenStr) { - status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, - (hid_t)mem_space_id, (hid_t)file_space_id, - (hid_t)xfer_plist_id, buf); - } /* end if */ - else - h5badArgument(env, "H5Dwrite_VLStrings: type is not variable length String"); - } /* end else */ + UNUSED(clss); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings */ - -herr_t -H5DwriteVL_str - (JNIEnv *env, hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, jobjectArray buf) -{ - herr_t status = -1; - char **wdata; - jsize size; - jsize i; + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_VLStrings: write buffer is NULL"); - size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); - wdata = (char**)HDmalloc((size_t)size * sizeof (char*)); + if ((isVlenStr = H5Tis_variable_str((hid_t)mem_type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (!wdata) { - h5JNIFatalError(env, "H5DwriteVL_str: cannot allocate buffer"); + if (isVlenStr) { + if ((status = H5DwriteVL_str(env, (hid_t)dataset_id, (hid_t)mem_type_id, + (hid_t)mem_space_id, (hid_t)file_space_id, (hid_t)xfer_plist_id, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); } /* end if */ - else { - HDmemset(wdata, 0, (size_t)size * sizeof(char*)); - for (i = 0; i < size; ++i) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); - - if (utf8) { - wdata[i] = (char*)HDmalloc((size_t)length + 1); - if (wdata[i]) { - HDmemset(wdata[i], 0, (size_t)length + 1); - HDstrncpy(wdata[i], utf8, (size_t)length + 1); - } /* end if */ - } /* end if */ - - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for (i = 0; i < size; ++i) */ - - status = H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, wdata); - - /* now free memory*/ - for (i = 0; i < size; i++) { - if(wdata[i]) { - HDfree(wdata[i]); - } /* end if */ - } /* end for */ - HDfree(wdata); - - if (status < 0) - h5libraryError(env); - } /* end else */ + else + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dwrite_VLStrings: datatype is not variable length String"); - return status; -} /* end H5DwriteVL_str */ +done: + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings */ /* * Class: hdf_hdf5lib_H5 @@ -1525,49 +1612,52 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref jlong dataset_id, jlong mem_type_id, jlong mem_space_id, jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) { - herr_t status = -1; - h5str_t h5str; - size_t size; - hdset_reg_ref_t *ref_data; - jint i; - jint n; - jstring jstr; + hdset_reg_ref_t *ref_data = NULL; + h5str_t h5str; + jstring jstr; + jsize i, n; + herr_t status = FAIL; - hid_t region = -1; - hid_t did = (hid_t) dataset_id; - hid_t tid = (hid_t) mem_type_id; - hid_t mem_sid = (hid_t) mem_space_id; - hid_t file_sid = (hid_t) file_space_id; + UNUSED(clss); - n = ENVPTR->GetArrayLength(ENVPAR buf); - size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ - ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); + HDmemset(&h5str, 0, sizeof(h5str_t)); - if (ref_data == NULL) { - h5JNIFatalError(env, "H5Dread_reg_ref: failed to allocate buff for read"); - return -1; - } /* end if */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dread_reg_ref: buf length < 0"); + } - status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data); + if (NULL == (ref_data = (hdset_reg_ref_t *) HDmalloc((size_t)n * sizeof(hdset_reg_ref_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dread_reg_ref: failed to allocate read buffer"); - if (status < 0) { - HDfree(ref_data); - h5JNIFatalError(env, "H5Dread_reg_ref: failed to read data"); - return -1; - } /* end if */ + if ((status = H5Dread((hid_t)dataset_id, (hid_t)mem_type_id, (hid_t)mem_space_id, (hid_t)file_space_id, xfer_plist_id, ref_data)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - HDmemset(&h5str, 0, sizeof(h5str_t)); h5str_new(&h5str, 1024); - for (i=0; iNewStringUTF(ENVPAR h5str.s); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + if (!h5str_sprintf(ENVONLY, &h5str, (hid_t)dataset_id, (hid_t)mem_type_id, &ref_data[i], 0, 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); } /* end for */ - h5str_free(&h5str); - HDfree(ref_data); +done: + if (h5str.s) + h5str_free(&h5str); + if (ref_data) + HDfree(ref_data); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref */ @@ -1582,17 +1672,19 @@ Java_hdf_hdf5lib_H5__1H5Dcreate2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type_id, jlong space_id, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) { - hid_t dset_id = -1; - const char *fileName; + const char *dsetName = NULL; + hid_t dset_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - dset_id = H5Dcreate2((hid_t)loc_id, fileName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); - if (dset_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate2: dataset name not pinned"); + + if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dsetName) + UNPIN_JAVA_STRING(ENVONLY, name, dsetName); return (jlong)dset_id; } /* end Java_hdf_hdf5lib_H5__1H5Dcreate2 */ @@ -1606,17 +1698,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dopen2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) { - hid_t dset_id = -1; - const char *fileName; + const char *dsetName = NULL; + hid_t dset_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - dset_id = H5Dopen2((hid_t)loc_id, fileName, (hid_t)access_plist); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); - if (dset_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dopen2: dataset name not pinned"); + + if ((dset_id = H5Dopen2((hid_t)loc_id, dsetName, (hid_t)access_plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dsetName) + UNPIN_JAVA_STRING(ENVONLY, name, dsetName); return (jlong)dset_id; } /* end Java_hdf_hdf5lib_H5__1H5Dopen2 */ @@ -1630,12 +1724,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Dcreate_1anon (JNIEnv *env, jclass clss, jlong loc_id, jlong type_id, jlong space_id, jlong dcpl_id, jlong dapl_id) { - hid_t dset_id = -1; + hid_t dset_id = H5I_INVALID_HID; + + UNUSED(clss); - dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, (hid_t)dapl_id); - if (dset_id < 0) - h5libraryError(env); + if ((dset_id = H5Dcreate_anon((hid_t)loc_id, (hid_t)type_id, (hid_t)space_id, (hid_t)dcpl_id, (hid_t)dapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)dset_id; } /* end Java_hdf_hdf5lib_H5__1H5Dcreate_1anon */ @@ -1650,9 +1746,12 @@ Java_hdf_hdf5lib_H5_H5Dget_1space_1status { H5D_space_status_t space_status = H5D_SPACE_STATUS_ERROR; + UNUSED(clss); + if (H5Dget_space_status((hid_t)loc_id, &space_status) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)space_status; } /* end Java_hdf_hdf5lib_H5_H5Dget_1space_1status */ @@ -1665,12 +1764,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dget_1access_1plist (JNIEnv *env, jclass clss, jlong loc_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Dget_access_plist((hid_t)loc_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Dget_access_plist((hid_t)loc_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Dget_1access_1plist */ @@ -1685,10 +1786,12 @@ Java_hdf_hdf5lib_H5_H5Dget_1offset { haddr_t offset = HADDR_UNDEF; - offset = H5Dget_offset((hid_t)loc_id); - if (offset == HADDR_UNDEF) - h5libraryError(env); + UNUSED(clss); + if (HADDR_UNDEF == (offset = H5Dget_offset((hid_t)loc_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)offset; } /* end Java_hdf_hdf5lib_H5_H5Dget_1offset */ @@ -1701,12 +1804,15 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size (JNIEnv *env, jclass clss, jlong dataset_id, jlong type_id, jlong space_id) { - hsize_t sz = 0; + hsize_t sz = 0; + + UNUSED(clss); - if (H5Dvlen_get_buf_size((hid_t)dataset_id, (hid_t)type_id, (hid_t)space_id, &sz) < 0) - h5libraryError(env); + if (H5Dvlen_get_buf_size((hid_t)dataset_id, (hid_t)type_id, (hid_t)space_id, &sz) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jlong)sz; +done: + return (jlong)sz; } /* end Java_hdf_hdf5lib_H5_H5Dvlen_1get_1buf_1size_1long */ /* @@ -1718,49 +1824,36 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dfill (JNIEnv *env, jclass clss, jbyteArray fill, jlong fill_type_id, jbyteArray buf, jlong buf_type_id, jlong space_id) { - herr_t status; - jbyte *fillP; - jbyte *buffP; jboolean isCopy1; jboolean isCopy2; + herr_t status; + jbyte *fillP = NULL; + jbyte *buffP = NULL; + UNUSED(clss); - if (buf == NULL) { - h5nullArgument(env, "H5Dfill: buf is NULL"); - } /* end if */ - else { - buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy2); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Dfill: buf not pinned"); - } /* end if */ - else { - if(fill) { - fillP = ENVPTR->GetByteArrayElements(ENVPAR fill, &isCopy1); - if (fillP == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); - h5JNIFatalError( env, "H5Dfill: fill not pinned"); - return; - } /* end if */ - } /* end if */ - else - fillP = NULL; - - status = H5Dfill((const void*)fillP, (hid_t)fill_type_id, (void*)buffP, (hid_t)buf_type_id, (hid_t)space_id); - if(fillP) { - /* free the buffer without copying back */ - ENVPTR->ReleaseByteArrayElements(ENVPAR fill, fillP, JNI_ABORT); - } /* end if */ - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - if (isCopy2 == JNI_TRUE) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0); - } /* end if */ - } /* end else */ - } + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dfill: buffer is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, buf, buffP, &isCopy2, "H5Dfill: buffer not pinned"); + + if (fill) { + PIN_BYTE_ARRAY(ENVONLY, fill, fillP, &isCopy1, "H5Dfill: fill buffer not pinned"); + } + + if ((status = H5Dfill((const void *)fillP, (hid_t)fill_type_id, (void *)buffP, (hid_t)buf_type_id, (hid_t)space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (fillP) { + UNPIN_BYTE_ARRAY(ENVONLY, fill, fillP, JNI_ABORT); + fillP = NULL; } + +done: + if (fillP) + UNPIN_BYTE_ARRAY(ENVONLY, fill, fillP, JNI_ABORT); + if (buffP) + UNPIN_BYTE_ARRAY(ENVONLY, buf, buffP, (status < 0) ? JNI_ABORT : 0); } /* end Java_hdf_hdf5lib_H5_H5Dfill */ /* @@ -1772,106 +1865,97 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dset_1extent (JNIEnv *env, jclass clss, jlong loc_id, jlongArray buf) { + jboolean isCopy; + hsize_t *dims = NULL; herr_t status; - hsize_t *dims; - jlong *buffP; jsize rank; - jboolean isCopy; + jlong *dimsBuf = NULL; int i = 0; - if (buf == NULL) { - h5nullArgument(env, "H5Dset_extent: buf is NULL"); - } /* end if */ - else { - rank = ENVPTR->GetArrayLength(ENVPAR buf); - if (rank <= 0) { - h5JNIFatalError(env, "H5Dset_extent: rank <=0"); - } /* end if */ - else { - buffP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); - if (buffP == NULL) { - h5JNIFatalError( env, "H5Dset_extent: buf not pinned"); - } /* end if */ - else { - dims = (hsize_t*)HDmalloc((size_t)rank * sizeof(hsize_t)); - for (i = 0; i< rank; i++) - dims[i] = (hsize_t)buffP[i]; - - status = H5Dset_extent((hid_t)loc_id, (hsize_t*)dims); - - HDfree (dims); - - /* free the buffer without copying back */ - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, JNI_ABORT); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - } /* end else */ - } /* end else */ + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dset_extent: buffer is NULL"); + + if ((rank = ENVPTR->GetArrayLength(ENVONLY, buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Dset_extent: buf length <= 0"); } + + PIN_LONG_ARRAY(ENVONLY, buf, dimsBuf, &isCopy, "H5Dset_extent: buffer not pinned"); + + if (NULL == (dims = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dset_extent: failed to allocate dataset dimension buffer"); + + for (i = 0; i < rank; i++) + dims[i] = (hsize_t)dimsBuf[i]; + + if ((status = H5Dset_extent((hid_t)loc_id, (hsize_t *)dims)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dims) + HDfree(dims); + if (dimsBuf) + UNPIN_LONG_ARRAY(ENVONLY, buf, dimsBuf, JNI_ABORT); } /* end Java_hdf_hdf5lib_H5_H5Dset_1extent */ static herr_t H5D_iterate_cb - (void* elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) { - JNIEnv *cbenv; - jint status; - jclass cls; - jmethodID mid; - jbyteArray elemArray; - jlongArray pointArray; - jsize size; + (void *elem, hid_t elem_id, unsigned ndim, const hsize_t *point, void *cb_data) { cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; + jbyteArray elemArray; + jlongArray pointArray; + jmethodID mid; + jobject visit_callback = wrapper->visit_callback; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = FAIL; + jsize size; + void *op_data = (void *)wrapper->op_data; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5D_iterate_cb: failed to attach current thread to JVM"); + } - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls == 0) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I"); - if (mid == 0) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (elem == NULL) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - if (point == NULL) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "([BJI[JLhdf/hdf5lib/callbacks/H5D_iterate_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - size = (jsize)H5Tget_size(elem_id); - elemArray = CBENVPTR->NewByteArray(CBENVPAR size); - if (elemArray == NULL) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - CBENVPTR->SetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem); + if (NULL == elem) + H5_NULL_ARGUMENT_ERROR(CBENVONLY, "H5D_iterate_cb: element buffer is NULL"); + if (NULL == point) + H5_NULL_ARGUMENT_ERROR(CBENVONLY, "H5D_iterate_cb: point is NULL"); - pointArray = CBENVPTR->NewLongArray(CBENVPAR 2); - if (pointArray == NULL) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - CBENVPTR->SetLongArrayRegion(CBENVPAR pointArray, 0, 2, (const jlong *)point); + if (!(size = (jsize)H5Tget_size(elem_id))) + H5_LIBRARY_ERROR(CBENVONLY); - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, (void*)elemArray, elem_id, ndim, pointArray, op_data); + if (NULL == (elemArray = CBENVPTR->NewByteArray(CBENVONLY, size))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - CBENVPTR->GetByteArrayRegion(CBENVPAR elemArray, 0, size, (jbyte *)elem); + CBENVPTR->SetByteArrayRegion(CBENVONLY, elemArray, 0, size, (jbyte *)elem); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - JVMPTR->DetachCurrentThread(JVMPAR); + if (NULL == (pointArray = CBENVPTR->NewLongArray(CBENVONLY, 2))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return status; + CBENVPTR->SetLongArrayRegion(CBENVONLY, pointArray, 0, 2, (const jlong *)point); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, (void *)elemArray, elem_id, ndim, pointArray, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + CBENVPTR->GetByteArrayRegion(CBENVONLY, elemArray, 0, size, (jbyte *)elem); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); + + return (herr_t)status; } /* end H5D_iterate_cb */ /* @@ -1884,41 +1968,31 @@ Java_hdf_hdf5lib_H5_H5Diterate (JNIEnv *env, jclass clss, jbyteArray buf, jlong buf_type, jlong space, jobject callback_op, jobject op_data) { - herr_t status = -1; - jboolean isCopy; - jbyte *buffP; - cb_wrapper wrapper = {callback_op, op_data}; + cb_wrapper wrapper = { callback_op, op_data }; + jboolean isCopy; + jbyte *iterBuf = NULL; + herr_t status = FAIL; - ENVPTR->GetJavaVM(ENVPAR &jvm); + UNUSED(clss); - if (op_data == NULL) { - h5nullArgument(env, "H5Diterate: op_data is NULL"); - } /* end if */ - else if (callback_op == NULL) { - h5nullArgument(env, "H5Diterate: callback_op is NULL"); - } /* end if */ - else if (buf == NULL) { - h5nullArgument(env, "H5Diterate: buf is NULL"); - } /* end if */ - else { - buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Diterate: buf not pinned"); - } /* end if */ - else { - status = H5Diterate((void*)buffP, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void*)&wrapper); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - if (isCopy == JNI_TRUE) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, 0); - } /* end if */ - } /* end else */ - } /* end else */ - } + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Diterate: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Diterate: callback_op is NULL"); + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Diterate: buffer is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, buf, iterBuf, &isCopy, "H5Diterate: buffer not pinned"); + + if ((status = H5Diterate((void *)iterBuf, (hid_t)buf_type, (hid_t)space, (H5D_operator_t)H5D_iterate_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (iterBuf) + UNPIN_BYTE_ARRAY(ENVONLY, buf, iterBuf, (status < 0) ? (JNI_ABORT) : ((isCopy == JNI_TRUE) ? 0 : JNI_ABORT)); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Diterate */ @@ -1932,8 +2006,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Dflush (JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Dflush((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* @@ -1945,11 +2024,14 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Drefresh (JNIEnv *env, jclass clss, jlong loc_id) { - if (H5Drefresh((hid_t)loc_id) < 0) - h5libraryError(env); -} + UNUSED(clss); + if (H5Drefresh((hid_t)loc_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: + return; +} #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 9c80461..1c5a5a9 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -39,6 +39,9 @@ extern "C" { #include "h5jni.h" #include "h5eImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; typedef struct _cb_wrapper { @@ -46,20 +49,6 @@ typedef struct _cb_wrapper { jobject op_data; } cb_wrapper; -#ifdef __cplusplus - #define CBENVPTR (cbenv) - #define CBENVPAR - #define JVMPTR (jvm) - #define JVMPAR - #define JVMPAR2 -#else /* __cplusplus */ - #define CBENVPTR (*cbenv) - #define CBENVPAR cbenv, - #define JVMPTR (*jvm) - #define JVMPAR jvm - #define JVMPAR2 jvm, -#endif /* __cplusplus */ - /********************/ /* Local Prototypes */ /********************/ @@ -77,12 +66,15 @@ Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 { unsigned int is_stack = 0; - if (stk_id < 0) { - h5badArgument(env, "H5Eauto_is_v2: invalid argument"); - } /* end if */ - else if (H5Eauto_is_v2((hid_t)stk_id, &is_stack) < 0) - h5libraryError(env); + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eauto_is_v2: invalid stack ID"); + if (H5Eauto_is_v2((hid_t)stk_id, &is_stack) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jboolean)is_stack; } /* end Java_hdf_hdf5lib_H5_H5Eauto_1is_1v2 */ @@ -95,20 +87,27 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eregister_1class (JNIEnv *env, jclass cls, jstring cls_name, jstring lib_name, jstring version) { - hid_t ret_val = -1; - const char* the_cls_name; - const char* the_lib_name; - const char* the_version; + const char* the_cls_name = NULL; + const char* the_lib_name = NULL; + const char* the_version = NULL; + hid_t ret_val = H5I_INVALID_HID; - PIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version); - if (the_cls_name != NULL && the_lib_name != NULL && the_version != NULL) { - ret_val = H5Eregister_class(the_cls_name, the_lib_name, the_version); + UNUSED(cls); - UNPIN_JAVA_STRING_THREE(cls_name, the_cls_name, lib_name, the_lib_name, version, the_version); + PIN_JAVA_STRING(ENVONLY, cls_name, the_cls_name, NULL, "H5Eregister_class: class name not pinned"); + PIN_JAVA_STRING(ENVONLY, lib_name, the_lib_name, NULL, "H5Eregister_class: lib name not pinned"); + PIN_JAVA_STRING(ENVONLY, version, the_version, NULL, "H5Eregister_class: version string not pinned"); - if (ret_val < 0) - h5libraryError(env); - } + if ((ret_val = H5Eregister_class(the_cls_name, the_lib_name, the_version)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (the_version) + UNPIN_JAVA_STRING(ENVONLY, version, the_version); + if (the_lib_name) + UNPIN_JAVA_STRING(ENVONLY, lib_name, the_lib_name); + if (the_cls_name) + UNPIN_JAVA_STRING(ENVONLY, cls_name, the_cls_name); return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Eregister_1class */ @@ -122,11 +121,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eunregister_1class (JNIEnv *env, jclass cls, jlong cls_id) { - if (cls_id < 0) { - h5badArgument(env, "H5Eunregister_class: invalid argument"); - } /* end if */ - else if (H5Eunregister_class((hid_t)cls_id) < 0) - h5libraryError(env); + UNUSED(cls); + + if (cls_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eunregister_class: invalid error class ID"); + + if (H5Eunregister_class((hid_t)cls_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eunregister_1class */ /* @@ -138,11 +142,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1msg (JNIEnv *env, jclass cls, jlong err_id) { - if (err_id < 0) { - h5badArgument(env, "H5Eclose_msg: invalid argument"); - } /* end if */ - else if (H5Eclose_msg((hid_t)err_id) < 0) - h5libraryError(env); + UNUSED(cls); + + if (err_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclose_msg: invalid error message ID"); + + if (H5Eclose_msg((hid_t)err_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eclose_1msg */ /* @@ -154,24 +163,23 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1msg (JNIEnv *env, jclass cls, jlong err_id, jint msg_type, jstring err_msg) { - hid_t ret_val = -1; - const char *the_err_msg; H5E_type_t error_msg_type = (H5E_type_t)msg_type; + const char *the_err_msg = NULL; + hid_t ret_val = H5I_INVALID_HID; - if (err_id < 0) { - h5badArgument(env, "H5Ecreate_msg: invalid argument"); - } /* end if */ - else { - PIN_JAVA_STRING(err_msg, the_err_msg); - if (the_err_msg != NULL) { - ret_val = H5Ecreate_msg((hid_t)err_id, error_msg_type, the_err_msg); + UNUSED(cls); - UNPIN_JAVA_STRING(err_msg, the_err_msg); + if (err_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ecreate_msg: invalid error class ID"); - if (ret_val < 0) - h5libraryError(env); - } - } /* end else */ + PIN_JAVA_STRING(ENVONLY, err_msg, the_err_msg, NULL, "H5Ecreate_msg: error message string not pinned"); + + if ((ret_val = H5Ecreate_msg((hid_t)err_id, error_msg_type, the_err_msg)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (the_err_msg) + UNPIN_JAVA_STRING(ENVONLY, err_msg, the_err_msg); return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Ecreate_1msg */ @@ -185,12 +193,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Ecreate_1stack (JNIEnv *env, jclass cls) { - hid_t ret_val = -1; + hid_t ret_val = H5I_INVALID_HID; + + UNUSED(cls); - ret_val = H5Ecreate_stack(); - if (ret_val < 0) - h5libraryError(env); + if ((ret_val = H5Ecreate_stack()) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Ecreate_1stack */ @@ -203,12 +213,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Eget_1current_1stack (JNIEnv *env, jclass cls) { - hid_t ret_val = -1; + hid_t ret_val = H5I_INVALID_HID; - ret_val = H5Eget_current_stack(); - if (ret_val < 0) - h5libraryError(env); + UNUSED(cls); + if ((ret_val = H5Eget_current_stack()) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Eget_1current_1stack */ @@ -221,11 +233,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclose_1stack (JNIEnv *env, jclass cls, jlong stk_id) { - if (stk_id < 0) { - h5badArgument(env, "H5Eclose_stack: invalid argument"); - } /* end if */ - else if (H5Eclose_stack((hid_t)stk_id) < 0) - h5libraryError(env); + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclose_stack: invalid error stack ID"); + + if (H5Eclose_stack((hid_t)stk_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eclose_1stack */ /* @@ -237,20 +254,24 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eprint2 (JNIEnv *env, jclass cls, jlong stk_id, jobject stream_obj) { - herr_t ret_val = -1; + herr_t ret_val = FAIL; + + UNUSED(cls); - if (stk_id < 0) { - h5badArgument(env, "H5Eprint2: invalid argument"); - } /* end if */ + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eprint2: invalid error stack ID"); + + if (!stream_obj) { + if ((ret_val = H5Eprint2((hid_t)stk_id, stdout)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } else { - if(!stream_obj) - ret_val = H5Eprint2((hid_t)stk_id, stdout); - else - ret_val = H5Eprint2((hid_t)stk_id, (FILE*)stream_obj); - - if (ret_val < 0) - h5libraryError(env); - } /* end else */ + if ((ret_val = H5Eprint2((hid_t)stk_id, (FILE *)stream_obj)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eprint2 */ /* @@ -262,43 +283,36 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1class_1name (JNIEnv *env, jclass cls, jlong cls_id) { - char *namePtr; - jstring str = NULL; - ssize_t buf_size; + jstring str = NULL; + ssize_t buf_size; + char *namePtr = NULL; + + UNUSED(cls); + + if (cls_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: invalid error class ID"); + + /* Get the length of the name */ + if ((buf_size = H5Eget_class_name((hid_t)cls_id, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!buf_size) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_class_name: no class name"); + + if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_class_name: malloc failed"); + + if ((H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + namePtr[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (namePtr) + HDfree(namePtr); - if (cls_id < 0) { - h5badArgument(env, "H5Eget_class_name: invalid argument"); - } /* end if */ - else { - /* get the length of the name */ - buf_size = H5Eget_class_name((hid_t)cls_id, NULL, 0); - - if (buf_size < 0) { - h5badArgument( env, "H5Eget_class_name: buf_size < 0"); - } /* end if */ - else if (buf_size == 0) { - h5badArgument( env, "H5Eget_class_name: No class name"); - } /* end else if */ - else { - buf_size++; /* add extra space for the null terminator */ - namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (namePtr == NULL) { - h5outOfMemory( env, "H5Eget_class_name: malloc failed"); - } /* end if */ - else { - buf_size = H5Eget_class_name((hid_t)cls_id, (char *)namePtr, (size_t)buf_size); - - if (buf_size < 0) { - HDfree(namePtr); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR namePtr); - HDfree(namePtr); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ return str; } /* end Java_hdf_hdf5lib_H5_H5Eget_1class_1name */ @@ -311,11 +325,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eset_1current_1stack (JNIEnv *env, jclass cls, jlong stk_id) { - if (stk_id < 0) { - h5badArgument(env, "H5Eset_current_stack: invalid argument"); - } /* end if */ - else if (H5Eset_current_stack((hid_t)stk_id) < 0) - h5libraryError(env); + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eset_current_stack: invalid error stack ID"); + + if (H5Eset_current_stack((hid_t)stk_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eset_1current_1stack */ /* @@ -327,11 +346,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Epop (JNIEnv *env, jclass cls, jlong stk_id, jlong count) { - if (stk_id < 0) { - h5badArgument(env, "H5Epop: invalid argument"); - } /* end if */ - else if (H5Epop((hid_t)stk_id, (size_t)count) < 0) - h5libraryError(env); + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epop: invalid error stack ID"); + + if (H5Epop((hid_t)stk_id, (size_t)count) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Epop */ /* @@ -344,35 +368,37 @@ Java_hdf_hdf5lib_H5_H5Epush2 (JNIEnv *env, jclass cls, jlong stk_id, jstring filename, jstring funcname, jint linenumber, jlong class_id, jlong major_id, jlong minor_id, jstring err_desc) { - herr_t ret_val = -1; - const char* fName; - const char* fncName; - const char* errMsg; - - if (stk_id < 0) { - h5badArgument(env, "H5Epush: invalid argument"); - } /* end if */ - else if (class_id < 0) { - h5badArgument(env, "H5Epush: invalid class_id argument"); - } /* end else if */ - else if (major_id < 0) { - h5badArgument(env, "H5Epush: invalid major_id argument"); - } /* end else if */ - else if (minor_id < 0) { - h5badArgument(env, "H5Epush: invalid minor_id argument"); - } /* end else if */ - else { - PIN_JAVA_STRING_THREE(filename, fName, funcname, fncName, err_desc, errMsg); - if (fName != NULL && fncName != NULL && errMsg != NULL) { - ret_val = H5Epush2((hid_t)stk_id, fName, fncName, (unsigned)linenumber, (hid_t)class_id, - (hid_t)major_id, (hid_t)minor_id, errMsg); - - UNPIN_JAVA_STRING_THREE(filename, fName, funcname, fncName, err_desc, errMsg); - - if (ret_val < 0) - h5libraryError(env); - } - } /* end else */ + const char *fName = NULL; + const char *fncName = NULL; + const char *errMsg = NULL; + herr_t ret_val = FAIL; + + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid error stack ID"); + if (class_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid error class ID"); + if (major_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid major error class ID"); + if (minor_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid minor error class ID"); + + PIN_JAVA_STRING(ENVONLY, filename, fName, NULL, "H5Epush2: filename not pinned"); + PIN_JAVA_STRING(ENVONLY, funcname, fncName, NULL, "H5Epush2: function name not pinned"); + PIN_JAVA_STRING(ENVONLY, err_desc, errMsg, NULL, "H5Epush2: error message not pinned"); + + if ((ret_val = H5Epush2((hid_t)stk_id, fName, fncName, (unsigned)linenumber, (hid_t)class_id, + (hid_t)major_id, (hid_t)minor_id, errMsg)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (errMsg) + UNPIN_JAVA_STRING(ENVONLY, err_desc, errMsg); + if (fncName) + UNPIN_JAVA_STRING(ENVONLY, funcname, fncName); + if (fName) + UNPIN_JAVA_STRING(ENVONLY, filename, fName); } /* end Java_hdf_hdf5lib_H5_H5Epush2 */ /* @@ -384,11 +410,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Eclear2 (JNIEnv *env, jclass cls, jlong stk_id) { - if (stk_id < 0) { - h5badArgument(env, "H5Eclear2: invalid argument"); - } /* end if */ - else if (H5Eclear2((hid_t)stk_id) < 0) - h5libraryError(env); + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eclear2: invalid error stack ID"); + + if (H5Eclear2((hid_t)stk_id) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Eclear2 */ /* @@ -400,57 +431,45 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Eget_1msg (JNIEnv *env, jclass cls, jlong msg_id, jintArray error_msg_type_list) { - char *namePtr; - jstring str = NULL; - jboolean isCopy; - ssize_t buf_size; - jint *theArray; - H5E_type_t error_msg_type; - - if (msg_id < 0) { - h5badArgument(env, "H5Eget_msg: invalid argument"); - } /* end if */ - else if (error_msg_type_list == NULL) { - h5nullArgument(env, "H5Eget_msg: error_msg_type_list is NULL"); - } /* end if */ - else { - /* get the length of the name */ - buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0); - - if ((buf_size < 0) || (buf_size == 0)) { - h5JNIFatalError(env, "H5Eget_msg: Invalid message"); - } /* end if */ - else { - buf_size++; /* add extra space for the null terminator */ - namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (namePtr == NULL) { - h5outOfMemory(env, "H5Eget_msg: malloc failed"); - } /* end if */ - else { - theArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR error_msg_type_list, &isCopy); - if (theArray == NULL) { - HDfree(namePtr); - h5JNIFatalError(env, "H5Eget_msg: error_msg_type_list not pinned"); - } /* end if */ - else { - buf_size = H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size); - - if (buf_size < 0) { - HDfree(namePtr); - ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = error_msg_type; - ENVPTR->ReleaseIntArrayElements(ENVPAR error_msg_type_list, theArray, 0); - - str = ENVPTR->NewStringUTF(ENVPAR namePtr); - HDfree(namePtr); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + H5E_type_t error_msg_type; + jstring str = NULL; + ssize_t buf_size; + jint *theArray = NULL; + char *namePtr = NULL; + + UNUSED(cls); + + if (msg_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: invalid error message ID"); + if (NULL == error_msg_type_list) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eget_msg: error_msg_type_list is NULL"); + + /* Get the length of the name */ + if ((buf_size = H5Eget_msg((hid_t)msg_id, NULL, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!buf_size) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: invalid message"); + + if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Eget_msg: malloc failed"); + + PIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, NULL, "H5Eget_msg: error_msg_type_list not pinned"); + + if ((H5Eget_msg((hid_t)msg_id, &error_msg_type, (char *)namePtr, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + namePtr[buf_size] = '\0'; + + theArray[0] = error_msg_type; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, error_msg_type_list, theArray, 0); + if (namePtr) + HDfree(namePtr); return str; } /* end Java_hdf_hdf5lib_H5_H5Eget_1msg */ @@ -466,14 +485,15 @@ Java_hdf_hdf5lib_H5_H5Eget_1num { ssize_t ret_val = -1; - if (stk_id < 0) { - h5badArgument(env, "H5Eget_num: invalid argument"); - } /* end if */ - else { - ret_val = H5Eget_num((hid_t)stk_id); - if (ret_val < 0) - h5libraryError(env); - } /* end else */ + UNUSED(cls); + + if (stk_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Eget_num: invalid error stack ID"); + + if ((ret_val = H5Eget_num((hid_t)stk_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Eget_1num */ @@ -481,52 +501,67 @@ static herr_t H5E_walk_cb (int nindx, const H5E_error2_t *info, void *cb_data) { - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str1, str2, str3; - jmethodID constructor; - jvalue args[7]; - jobject cb_info_t = NULL; cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I"); - if (mid != 0) { - args[0].j = info->cls_id; - args[1].j = info->maj_num; - args[2].j = info->min_num; - args[3].i = (jint)info->line; - str1 = CBENVPTR->NewStringUTF(CBENVPAR info->func_name); - args[4].l = str1; - str2 = CBENVPTR->NewStringUTF(CBENVPAR info->file_name); - args[5].l = str2; - str3 = CBENVPTR->NewStringUTF(CBENVPAR info->desc); - args[6].l = str3; - // get a reference to your class if you don't have it already - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5E_error2_t"); - if (cls != 0) { - // get a reference to the constructor; the name is - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); - if (constructor != 0) { - cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (cb_info_t == NULL) { - printf("FATAL ERROR: hdf/hdf5lib/structs/H5E_error2_t: Creation failed\n"); - } - else { - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, nindx, cb_info_t, op_data); - } - } /* end if (constructor != 0) */ - } /* end if(cls != 0) */ - } /* end if (mid != 0) */ - } /* end if (cls != 0) */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); + jmethodID constructor; + jmethodID mid; + jobject visit_callback = wrapper->visit_callback; + jstring str1, str2, str3; + jobject cb_info_t = NULL; + jvalue args[7]; + JNIEnv *cbenv = NULL; + jclass cls; + void *op_data = (void *)wrapper->op_data; + jint status = FAIL; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5E_walk_cb: failed to attach current thread to JVM"); + } + + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[0].j = info->cls_id; + args[1].j = info->maj_num; + args[2].j = info->min_num; + args[3].i = (jint)info->line; + + if (NULL == (str1 = CBENVPTR->NewStringUTF(CBENVONLY, info->func_name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[4].l = str1; + + if (NULL == (str2 = CBENVPTR->NewStringUTF(CBENVONLY, info->file_name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[5].l = str2; + + if (NULL == (str3 = CBENVPTR->NewStringUTF(CBENVONLY, info->desc))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[6].l = str3; + + /* Get a reference to your class if you don't have it already */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5E_error2_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(JJJILjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, nindx, cb_info_t, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + +done: + if (CBENVONLY) + JVMPTR->DetachCurrentThread(JVMPAR); + return (herr_t)status; } /* end H5E_walk_cb */ @@ -539,15 +574,23 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ewalk2 (JNIEnv *env, jclass cls, jlong stk_id, jlong direction, jobject callback_op, jobject op_data) { - cb_wrapper wrapper = {callback_op, op_data}; + cb_wrapper wrapper = { callback_op, op_data }; + + UNUSED(cls); + + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ewalk2: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ewalk2: callback_op is NULL"); - ENVPTR->GetJavaVM(ENVPAR &jvm); + if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void *)&wrapper) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Ewalk2: op_data or callback_op is NULL"); - } /* end if */ - else if (H5Ewalk2(stk_id, (H5E_direction_t)direction, (H5E_walk2_t)H5E_walk_cb, (void*)&wrapper) < 0) - h5libraryError(env); +done: + return; } /* end iJava_hdf_hdf5lib_H5_H5Ewalk2f */ #ifdef __cplusplus diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 80adffb..624c788 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -28,7 +28,10 @@ extern "C" { #include "h5fImp.h" #include "h5util.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -39,18 +42,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fopen (JNIEnv *env, jclass clss, jstring name, jint flags, jlong access_id) { - hid_t status = -1; - const char *fileName; + const char *fileName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fopen: file name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Fopen */ @@ -64,18 +68,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fcreate (JNIEnv *env, jclass clss, jstring name, jint flags, jlong create_id, jlong access_id) { - hid_t status = -1; - const char *fileName; + const char *fileName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fcreate: file name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Fcreate */ @@ -89,12 +94,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fflush (JNIEnv *env, jclass clss, jlong object_id, jint scope) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Fflush((hid_t)object_id, (H5F_scope_t)scope ); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Fflush((hid_t)object_id, (H5F_scope_t)scope)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Fflush */ @@ -107,34 +114,29 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Fget_1name (JNIEnv *env, jclass cls, jlong file_id) { - char *namePtr; - jstring str = NULL; - ssize_t buf_size; - - /* get the length of the name */ - buf_size = H5Fget_name((hid_t)file_id, NULL, 0); - - if (buf_size <= 0) { - h5badArgument(env, "H5Fget_name: buf_size <= 0"); - } /* end if */ - else { - buf_size++; /* add extra space for the null terminator */ - namePtr = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (namePtr == NULL) { - h5outOfMemory(env, "H5Fget_name: malloc failed"); - } /* end if */ - else { - buf_size = H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size); - if (buf_size < 0) { - HDfree(namePtr); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR namePtr); - HDfree(namePtr); - }/* end else */ - }/* end else */ - }/* end else */ + jstring str = NULL; + ssize_t buf_size; + char *namePtr = NULL; + + UNUSED(cls); + + /* Get the length of the name */ + if ((buf_size = H5Fget_name((hid_t)file_id, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (namePtr = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_name: malloc failed"); + + if ((H5Fget_name((hid_t)file_id, namePtr, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + namePtr[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, namePtr))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (namePtr) + HDfree(namePtr); return str; } /* end Java_hdf_hdf5lib_H5_H5Fget_1name */ @@ -148,24 +150,26 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1hdf5 (JNIEnv *env, jclass clss, jstring name) { + const char *fileName = NULL; htri_t bval = JNI_FALSE; + + UNUSED(clss); + #ifdef H5_NO_DEPRECATED_SYMBOLS - h5unimplemented(env, "H5Fis_hdf5: not implemented"); -#else - const char *fileName; + H5_UNIMPLEMENTED(ENVONLY, "H5Fis_hdf5: not implemented"); +#endif - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - bval = H5Fis_hdf5(fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fis_hdf5: file name not pinned"); - UNPIN_JAVA_STRING(name, fileName); + if ((bval = H5Fis_hdf5(fileName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } -#endif return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Fis_1hdf5 */ @@ -178,20 +182,21 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fis_1accessible (JNIEnv *env, jclass clss, jstring name, jlong file_id) { + const char *fileName = NULL; htri_t bval = JNI_FALSE; - const char *fileName; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - bval = H5Fis_accessible(fileName, (hid_t)file_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fis_accessible: file name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5Fis_accessible(fileName, (hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Fis_1accessible */ @@ -205,12 +210,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist (JNIEnv *env, jclass clss, jlong file_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Fget_create_plist((hid_t)file_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Fget_create_plist((hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist */ @@ -223,12 +230,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist (JNIEnv *env, jclass clss, jlong file_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Fget_access_plist((hid_t)file_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Fget_access_plist((hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Fget_1access_1plist */ @@ -243,9 +252,12 @@ Java_hdf_hdf5lib_H5_H5Fget_1intent { unsigned intent = 0; + UNUSED(cls); + if (H5Fget_intent((hid_t)file_id, &intent) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)intent; } /* end Java_hdf_hdf5lib_H5_H5Fget_1intent */ @@ -258,14 +270,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Fclose (JNIEnv *env, jclass clss, jlong file_id) { - herr_t status = -1; + herr_t status = FAIL; - if (file_id > 0) - status = H5Fclose((hid_t)file_id ); + UNUSED(clss); - if (status < 0) - h5libraryError(env); + if ((status = H5Fclose((hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)status; } /* end Java_hdf_hdf5lib_H5__1H5Fclose */ @@ -278,18 +290,19 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fmount (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong child_id, jlong plist_id) { - herr_t status = -1; - const char *fileName; + const char *fileName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fmount: file name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Fmount */ @@ -303,18 +316,19 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Funmount (JNIEnv *env, jclass clss, jlong loc_id, jstring name) { - herr_t status = -1; - const char *fileName; + const char *fileName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - status = H5Funmount((hid_t)loc_id, fileName); + UNUSED(clss); - UNPIN_JAVA_STRING(name, fileName); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Funmount: file name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Funmount((hid_t)loc_id, fileName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Funmount */ @@ -328,11 +342,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1freespace (JNIEnv *env, jclass cls, jlong file_id) { - hssize_t ret_val = H5Fget_freespace((hid_t)file_id); + hssize_t ret_val = -1; + + UNUSED(cls); - if (ret_val < 0) - h5libraryError(env); + if ((ret_val = H5Fget_freespace((hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Fget_1freespace */ @@ -345,12 +362,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Freopen (JNIEnv *env, jclass clss, jlong file_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Freopen((hid_t)file_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Freopen((hid_t)file_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Freopen */ @@ -364,47 +383,40 @@ Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids (JNIEnv *env, jclass cls, jlong file_id, jint types, jlong maxObjs, jlongArray obj_id_list) { - ssize_t ret_val = -1; - jlong *obj_id_listP; - jboolean isCopy; - hid_t *id_list; - size_t rank; - size_t i; - - if (obj_id_list == NULL) { - h5nullArgument(env, "H5Fget_obj_ids: obj_id_list is NULL"); - } /* end if */ - else { - obj_id_listP = ENVPTR->GetLongArrayElements(ENVPAR obj_id_list, &isCopy); - if (obj_id_listP == NULL) { - h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not pinned"); - } /* end if */ - else { - rank = (size_t)ENVPTR->GetArrayLength(ENVPAR obj_id_list); - - id_list = (hid_t *)HDmalloc(rank * sizeof(hid_t)); - if (id_list == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT); - h5JNIFatalError(env, "H5Fget_obj_ids: obj_id_list not converted to hid_t"); - } /* end if */ - else { - ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list); - - if (ret_val < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, JNI_ABORT); - HDfree(id_list); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < rank; i++) { - obj_id_listP[i] = (jlong)id_list[i]; - } /* end for */ - HDfree(id_list); - ENVPTR->ReleaseLongArrayElements(ENVPAR obj_id_list, obj_id_listP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + ssize_t ret_val = -1; + size_t i; + jsize rank; + jlong *obj_id_listP = NULL; + hid_t *id_list = NULL; + + UNUSED(cls); + + if (NULL == obj_id_list) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fget_obj_ids: obj_id_list is NULL"); + + PIN_LONG_ARRAY(ENVONLY, obj_id_list, obj_id_listP, &isCopy, "H5Fget_obj_ids: obj_id_list not pinned"); + + if ((rank = ENVPTR->GetArrayLength(ENVONLY, obj_id_list)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_obj_ids: obj_id_list length < 0"); + } + + if (NULL == (id_list = (hid_t *) HDmalloc((size_t)rank * sizeof(hid_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Fget_obj_ids: malloc failed"); + + if ((ret_val = H5Fget_obj_ids((hid_t)file_id, (unsigned int)types, (size_t)maxObjs, id_list)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (size_t)rank; i++) { + obj_id_listP[i] = (jlong)id_list[i]; + } /* end for */ + +done: + if (id_list) + HDfree(id_list); + if (obj_id_listP) + UNPIN_LONG_ARRAY(ENVONLY, obj_id_list, obj_id_listP, (ret_val < 0) ? JNI_ABORT : 0); return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1ids */ @@ -418,11 +430,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Fget_1obj_1count (JNIEnv *env, jclass cls, jlong file_id, jint types) { - ssize_t ret_val = H5Fget_obj_count((hid_t)file_id, (unsigned int)types); + ssize_t ret_val = -1; + + UNUSED(cls); - if (ret_val < 0) - h5libraryError(env); + if ((ret_val = H5Fget_obj_count((hid_t)file_id, (unsigned int)types)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Fget_1obj_1count_1long */ @@ -437,9 +452,12 @@ Java_hdf_hdf5lib_H5_H5Fget_1filesize { hsize_t size = 0; - if (H5Fget_filesize ((hid_t)file_id, &size) < 0) - h5libraryError(env); + UNUSED(clss); + + if (H5Fget_filesize((hid_t)file_id, &size) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong) size; } /* end Java_hdf_hdf5lib_H5_H5Fget_1filesize */ @@ -454,9 +472,12 @@ Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate { double rate = 0.0; + UNUSED(cls); + if (H5Fget_mdc_hit_rate((hid_t)file_id, &rate) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); +done: return (jdouble)rate; } /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1hit_1rate */ @@ -469,33 +490,37 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size (JNIEnv *env, jclass cls, jlong file_id, jlongArray metadata_cache) { - jint size = 0; - jlong *metadata_cache_ptr; - size_t max_size = 0, min_clean_size = 0, cur_size = 0; - int cur_num_entries = -1; - jboolean isCopy; - - if (metadata_cache == NULL) { - h5nullArgument(env, "H5Fget_mdc_size: metadata_cache is NULL"); - } /* end if */ - else { - size = (int)ENVPTR->GetArrayLength(ENVPAR metadata_cache); - if (size < 3) { - h5badArgument(env, "H5Fget_mdc_size: length of metadata_cache < 3."); - } /* end if */ - else { - if (H5Fget_mdc_size((hid_t)file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) { - h5libraryError(env); - } /* end if */ - else { - metadata_cache_ptr = ENVPTR->GetLongArrayElements(ENVPAR metadata_cache, &isCopy); - metadata_cache_ptr[0] = (jlong)max_size; - metadata_cache_ptr[1] = (jlong)min_clean_size; - metadata_cache_ptr[2] = (jlong)cur_size; - ENVPTR->ReleaseLongArrayElements(ENVPAR metadata_cache, metadata_cache_ptr, 0); - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + size_t max_size = 0, min_clean_size = 0, cur_size = 0; + jlong *metadata_cache_ptr = NULL; + jsize size = 0; + int cur_num_entries = -1; + + UNUSED(cls); + + if (NULL == metadata_cache) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_size: metadata cache array is NULL"); + + if ((size = ENVPTR->GetArrayLength(ENVONLY, metadata_cache)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_size: metadata_cache length < 0"); + } + + if (size < 3) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_size: length of metadata_cache array < 3"); + + if (H5Fget_mdc_size((hid_t)file_id, &max_size, &min_clean_size, &cur_size, &cur_num_entries) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_LONG_ARRAY(ENVONLY, metadata_cache, metadata_cache_ptr, &isCopy, "H5Fget_mdc_size: metadata_cache array not pinned"); + + metadata_cache_ptr[0] = (jlong)max_size; + metadata_cache_ptr[1] = (jlong)min_clean_size; + metadata_cache_ptr[2] = (jlong)cur_size; + +done: + if (metadata_cache_ptr) + UNPIN_LONG_ARRAY(ENVONLY, metadata_cache, metadata_cache_ptr, 0); return (jint)cur_num_entries; } /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1size */ @@ -509,31 +534,36 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Fget_1info (JNIEnv *env, jclass clss, jlong obj_id) { - H5F_info2_t finfo; - jvalue args[9]; + H5F_info2_t finfo; jobject ihinfobuf; + jvalue args[9]; jobject ret_obj = NULL; - if (H5Fget_info2((hid_t)obj_id, &finfo) < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].j = (jlong)finfo.sohm.msgs_info.index_size; - args[1].j = (jlong)finfo.sohm.msgs_info.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf = ret_obj; - - args[0].i = (jint)finfo.super.version; - args[1].j = (jlong)finfo.super.super_size; - args[2].j = (jlong)finfo.super.super_ext_size; - args[3].i = (jint)finfo.free.version; - args[4].j = (jlong)finfo.free.meta_size; - args[5].j = (jlong)finfo.free.tot_space; - args[6].j = (jint)finfo.sohm.version; - args[7].j = (jlong)finfo.sohm.hdr_size; - args[8].l = ihinfobuf; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5F_info2_t", "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args); - } /* end else */ + UNUSED(clss); + + if (H5Fget_info2((hid_t)obj_id, &finfo) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].j = (jlong)finfo.sohm.msgs_info.index_size; + args[1].j = (jlong)finfo.sohm.msgs_info.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + + ihinfobuf = ret_obj; + + args[0].i = (jint)finfo.super.version; + args[1].j = (jlong)finfo.super.super_size; + args[2].j = (jlong)finfo.super.super_ext_size; + args[3].i = (jint)finfo.free.version; + args[4].j = (jlong)finfo.free.meta_size; + args[5].j = (jlong)finfo.free.tot_space; + args[6].j = (jint)finfo.sohm.version; + args[7].j = (jlong)finfo.sohm.hdr_size; + args[8].l = ihinfobuf; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5F_info2_t", "(IJJIJJIJLhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + +done: return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Fget_1info */ @@ -546,8 +576,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats (JNIEnv *env, jclass cls, jlong file_id) { + UNUSED(cls); + if (H5Freset_mdc_hit_rate_stats((hid_t)file_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Freset_1mdc_1hit_1rate_1stats */ /* @@ -559,8 +594,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache (JNIEnv *env, jclass cls, jlong file_id) { + UNUSED(cls); + if (H5Fclear_elink_file_cache((hid_t)file_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Fclear_1elink_1file_1cache */ /* @@ -572,8 +612,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write (JNIEnv *env, jclass cls, jlong file_id) { + UNUSED(cls); + if (H5Fstart_swmr_write((hid_t)file_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Fstart_1swmr_1write */ /* @@ -585,8 +630,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging (JNIEnv *env, jclass cls, jlong file_id) { + UNUSED(cls); + if (H5Fstart_mdc_logging((hid_t)file_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Fstart_1mdc_1logging */ /* @@ -598,8 +648,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging (JNIEnv *env, jclass cls, jlong file_id) { + UNUSED(cls); + if (H5Fstop_mdc_logging((hid_t)file_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Fstop_1mdc_1logging */ /* @@ -611,32 +666,38 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status (JNIEnv *env, jclass cls, jlong file_id, jbooleanArray mdc_logging_status) { + jboolean *mdc_logging_status_ptr = NULL; + jboolean isCopy; hbool_t is_enabled; hbool_t is_currently_logging; - jboolean *mdc_logging_status_ptr; - jint size; - jboolean isCopy; + jsize size; + + UNUSED(cls); + + if (NULL == mdc_logging_status) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_logging_status: mdc_logging_status is NULL"); + + if ((size = ENVPTR->GetArrayLength(ENVONLY, mdc_logging_status)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_logging_status: mdc_logging_status length < 0"); + } + + if (size < 2) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Fget_mdc_logging_status: length of mdc_logging_status < 2"); - if (mdc_logging_status == NULL) { - h5nullArgument(env, "H5Fget_mdc_logging_status: mdc_logging_status is NULL"); - } /* end if */ - else { - size = (int)ENVPTR->GetArrayLength(ENVPAR mdc_logging_status); - if (size < 2) { - h5badArgument(env, "H5Fget_mdc_logging_status: length of mdc_logging_status < 2."); - } /* end if */ - else { - if (H5Fget_mdc_logging_status((hid_t)file_id, &is_enabled, &is_currently_logging) < 0) { - h5libraryError(env); - } /* end if */ - else { - mdc_logging_status_ptr = ENVPTR->GetBooleanArrayElements(ENVPAR mdc_logging_status, &isCopy); - mdc_logging_status_ptr[0] = (jboolean)is_enabled; - mdc_logging_status_ptr[1] = (jboolean)is_currently_logging; - ENVPTR->ReleaseBooleanArrayElements(ENVPAR mdc_logging_status, mdc_logging_status_ptr, 0); - } /* end else */ - } /* end else */ - } /* end else */ + if (H5Fget_mdc_logging_status((hid_t)file_id, &is_enabled, &is_currently_logging) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_BOOL_ARRAY(ENVONLY, mdc_logging_status, mdc_logging_status_ptr, &isCopy, "H5Fget_mdc_logging_status: mdc_logging_status array not pinned"); + + mdc_logging_status_ptr[0] = (jboolean)is_enabled; + mdc_logging_status_ptr[1] = (jboolean)is_currently_logging; + +done: + if (mdc_logging_status_ptr) + UNPIN_BOOL_ARRAY(ENVONLY, mdc_logging_status, mdc_logging_status_ptr, 0); + + return; } /* end Java_hdf_hdf5lib_H5_H5Fget_1mdc_1logging_1status */ /* @@ -648,17 +709,18 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fset_1dset_1no_1attrs_1hint (JNIEnv *env, jclass clss, jlong file_id, jboolean minimize) { - herr_t retVal = -1; - hbool_t minimize_val; + hbool_t minimize_val; + herr_t retVal = FAIL; + + UNUSED(clss); + + minimize_val = (minimize == JNI_TRUE) ? TRUE : FALSE; - if (minimize == JNI_TRUE) - minimize_val = TRUE; - else - minimize_val = FALSE; + if ((retVal = H5Fset_dset_no_attrs_hint((hid_t)file_id, (hbool_t)minimize_val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Fset_dset_no_attrs_hint((hid_t)file_id, (hbool_t)minimize_val); - if (retVal < 0) - h5libraryError(env); +done: + return; } /* @@ -670,17 +732,18 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Fget_1dset_1no_1attrs_1hint (JNIEnv *env, jclass clss, jlong file_id) { - hbool_t minimize = FALSE; - jboolean bval = JNI_FALSE; + jboolean bval = JNI_FALSE; + hbool_t minimize = FALSE; - if (H5Fget_dset_no_attrs_hint((hid_t)file_id, (hbool_t *)&minimize) < 0) { - h5libraryError(env); - } - else { - if (minimize == TRUE) - bval = JNI_TRUE; - } /* end else */ + UNUSED(clss); + + if (H5Fget_dset_no_attrs_hint((hid_t)file_id, (hbool_t *)&minimize) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (minimize == TRUE) + bval = JNI_TRUE; +done: return bval; } @@ -693,11 +756,15 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds (JNIEnv *env, jclass clss, jlong file_id, jint low, jint high) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Fset_libver_bounds((hid_t)file_id, (H5F_libver_t)low, (H5F_libver_t)high)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Fset_libver_bounds((hid_t)file_id, (H5F_libver_t)low, (H5F_libver_t)high); - if(retVal < 0) - h5libraryError(env); +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Fset_1libver_1bounds */ diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index fe253f9..410a249 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -72,7 +72,7 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 * Signature: (Ljava/lang/String;J)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Fis_1ccessible +Java_hdf_hdf5lib_H5_H5Fis_1accessible (JNIEnv*, jclass, jstring, jlong); /* diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c index 42c042a..8adabca 100644 --- a/java/src/jni/h5gImp.c +++ b/java/src/jni/h5gImp.c @@ -29,7 +29,10 @@ extern "C" { #include "h5util.h" #include "h5gImp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -40,12 +43,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Gclose (JNIEnv *env, jclass clss, jlong group_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Gclose((hid_t)group_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Gclose((hid_t)group_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Gclose */ @@ -63,33 +68,46 @@ jobject create_H5G_info_t (JNIEnv *env, H5G_info_t group_info) { - jclass cls; + jfieldID fid_storage_type, fid_nlinks, fid_max_corder, fid_mounted; jboolean jmounted; + jclass cls; jint storage_type; jobject obj = NULL; - jfieldID fid_storage_type, fid_nlinks, fid_max_corder, fid_mounted; - cls = ENVPTR->FindClass(ENVPAR "hdf/hdf5lib/structs/H5G_info_t"); - if (cls != NULL) { - obj = ENVPTR->AllocObject(ENVPAR cls); - if (obj != NULL) { - if ((fid_storage_type = ENVPTR->GetFieldID(ENVPAR cls, "storage_type", "I")) != NULL) { - if ((fid_nlinks = ENVPTR->GetFieldID(ENVPAR cls, "nlinks", "J")) != NULL) { - if ((fid_max_corder = ENVPTR->GetFieldID(ENVPAR cls, "max_corder", "J")) != NULL) { - if ((fid_mounted = ENVPTR->GetFieldID(ENVPAR cls, "mounted", "Z")) != NULL) { - jmounted = (group_info.mounted==0) ? JNI_FALSE : JNI_TRUE; - storage_type = (jint)group_info.storage_type; - - ENVPTR->SetIntField(ENVPAR obj, fid_storage_type, (jint)storage_type); - ENVPTR->SetLongField(ENVPAR obj, fid_nlinks, (jlong)group_info.nlinks); - ENVPTR->SetLongField(ENVPAR obj, fid_max_corder, (jlong)group_info.max_corder); - ENVPTR->SetBooleanField(ENVPAR obj, fid_mounted, jmounted); - } - } - } - } - } - } + if (NULL == (cls = ENVPTR->FindClass(ENVONLY, "hdf/hdf5lib/structs/H5G_info_t"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (obj = ENVPTR->AllocObject(ENVONLY, cls))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid_storage_type = ENVPTR->GetFieldID(ENVONLY, cls, "storage_type", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid_nlinks = ENVPTR->GetFieldID(ENVONLY, cls, "nlinks", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid_max_corder = ENVPTR->GetFieldID(ENVONLY, cls, "max_corder", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid_mounted = ENVPTR->GetFieldID(ENVONLY, cls, "mounted", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + jmounted = (group_info.mounted == 0) ? JNI_FALSE : JNI_TRUE; + storage_type = (jint)group_info.storage_type; + + ENVPTR->SetIntField(ENVONLY, obj, fid_storage_type, (jint)storage_type); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetLongField(ENVONLY, obj, fid_nlinks, (jlong)group_info.nlinks); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetLongField(ENVONLY, obj, fid_max_corder, (jlong)group_info.max_corder); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetBooleanField(ENVONLY, obj, fid_mounted, jmounted); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: return obj; } /* end create_H5G_info_t */ @@ -103,17 +121,19 @@ Java_hdf_hdf5lib_H5__1H5Gcreate2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) { - hid_t group_id = -1; - const char *gName; + const char *grpName = NULL; + hid_t group_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, gName); - if (gName != NULL) { - group_id = H5Gcreate2((hid_t)loc_id, gName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, gName); - if (group_id < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gcreate2: group name not pinned"); + + if ((group_id = H5Gcreate2((hid_t)loc_id, grpName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); return (jlong)group_id; } /* end Java_hdf_hdf5lib_H5__1H5Gcreate2 */ @@ -127,12 +147,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gcreate_1anon (JNIEnv *env, jclass cls, jlong loc_id, jlong gcpl_id, jlong gapl_id) { - hid_t group_id = -1; + hid_t group_id = H5I_INVALID_HID; - group_id = H5Gcreate_anon((hid_t)loc_id, (hid_t)gcpl_id, (hid_t)gapl_id); - if (group_id < 0) - h5libraryError(env); + UNUSED(cls); + if ((group_id = H5Gcreate_anon((hid_t)loc_id, (hid_t)gcpl_id, (hid_t)gapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)group_id; } /* end Java_hdf_hdf5lib_H5__1H5Gcreate_1anon */ @@ -145,18 +167,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Gopen2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) { - hid_t group_id = -1; - const char *gName; + const char *grpName = NULL; + hid_t group_id = H5I_INVALID_HID; - PIN_JAVA_STRING(name, gName); - if (gName != NULL) { - group_id = H5Gopen2((hid_t)loc_id, gName, (hid_t)access_plist_id ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, gName); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gopen2: group name not pinned"); - if (group_id < 0) - h5libraryError(env); - } + if ((group_id = H5Gopen2((hid_t)loc_id, grpName, (hid_t)access_plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); return (jlong)group_id; } /* end Java_hdf_hdf5lib_H5__1H5Gopen2 */ @@ -171,11 +194,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Gget_1create_1plist (JNIEnv *env, jclass cls, jlong loc_id) { - hid_t plist_id = H5Gget_create_plist((hid_t)loc_id); + hid_t plist_id = H5I_INVALID_HID; - if (plist_id < 0) - h5libraryError(env); + UNUSED(cls); + if ((plist_id = H5Gget_create_plist((hid_t)loc_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)plist_id; } /* end Java_hdf_hdf5lib_H5_H5Gget_1create_1plist */ @@ -188,14 +214,18 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info (JNIEnv *env, jclass cls, jlong loc_id) { - jobject obj = NULL; H5G_info_t group_info; + jobject obj = NULL; + + UNUSED(cls); if (H5Gget_info((hid_t)loc_id, &group_info) < 0) - h5libraryError(env); - else - obj = create_H5G_info_t(env, group_info); + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (obj = create_H5G_info_t(env, group_info))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_info: unable to create H5G_info_t object"); +done: return obj; } /* end Java_hdf_hdf5lib_H5_H5Gget_1info */ @@ -208,23 +238,27 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name (JNIEnv *env, jclass cls, jlong loc_id, jstring name, jlong lapl_id) { - jobject obj = NULL; - herr_t ret_val = -1; - const char *gName; H5G_info_t group_info; + const char *grpName = NULL; + jobject obj = NULL; + herr_t ret_val = FAIL; + + UNUSED(cls); - PIN_JAVA_STRING(name, gName); - if (gName != NULL) { - ret_val = H5Gget_info_by_name((hid_t)loc_id, gName, &group_info, (hid_t)lapl_id); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gget_info_by_name: group name not pinned"); - UNPIN_JAVA_STRING(name, gName); + if ((ret_val = H5Gget_info_by_name((hid_t)loc_id, grpName, &group_info, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (ret_val < 0) - h5libraryError(env); - else - obj = create_H5G_info_t(env, group_info); + if (NULL == (obj = create_H5G_info_t(env, group_info))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_info_by_name: unable to create H5G_info_t object"); } +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); + return obj; } /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name */ @@ -238,26 +272,30 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx (JNIEnv *env, jclass cls, jlong loc_id, jstring name, jint index_type, jint order, jlong n, jlong lapl_id) { - jobject obj = NULL; - herr_t ret_val = -1; - const char *gName; - H5G_info_t group_info; - H5_index_t cindex_type = (H5_index_t)index_type; - H5_iter_order_t corder = (H5_iter_order_t)order; - - PIN_JAVA_STRING(name, gName); - if (gName != NULL) { - ret_val = H5Gget_info_by_idx((hid_t)loc_id, gName, cindex_type, - corder, (hsize_t)n, &group_info, (hid_t)lapl_id); - - UNPIN_JAVA_STRING(name, gName); - - if (ret_val < 0) - h5libraryError(env); - else - obj = create_H5G_info_t(env, group_info); + H5_iter_order_t corder = (H5_iter_order_t)order; + H5_index_t cindex_type = (H5_index_t)index_type; + H5G_info_t group_info; + const char *grpName = NULL; + jobject obj = NULL; + herr_t ret_val = FAIL; + + UNUSED(cls); + + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gget_info_by_idx: group name not pinned"); + + if ((ret_val = H5Gget_info_by_idx((hid_t)loc_id, grpName, cindex_type, + corder, (hsize_t)n, &group_info, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (obj = create_H5G_info_t(env, group_info))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_info_by_idx: unable to create H5G_info_t object"); } +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); + return obj; } /* end Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx */ @@ -270,8 +308,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Gflush (JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Gflush((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Gflush */ /* @@ -283,8 +326,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Grefresh (JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Grefresh((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Grefresh */ diff --git a/java/src/jni/h5iImp.c b/java/src/jni/h5iImp.c index b8bd1cd..a367802 100644 --- a/java/src/jni/h5iImp.c +++ b/java/src/jni/h5iImp.c @@ -27,7 +27,10 @@ extern "C" { #include "h5jni.h" #include "h5iImp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -40,10 +43,12 @@ Java_hdf_hdf5lib_H5_H5Iget_1type { H5I_type_t retVal = H5I_BADID; - retVal = H5Iget_type((hid_t)obj_id); - if (retVal == H5I_BADID) - h5libraryError(env); + UNUSED(clss); + + if (H5I_BADID == (retVal = H5Iget_type((hid_t)obj_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Iget_1type */ @@ -56,32 +61,32 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name_1long (JNIEnv *env, jclass clss, jlong obj_id, jobjectArray name, jlong buf_size) { - char *aName; - jstring str; - hssize_t size = -1; - long bs; - - bs = (long)buf_size; - if (bs <= 0) { - h5badArgument(env, "H5Iget_name: buf_size <= 0"); - } /* end if */ - else { - aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); - if (aName == NULL) { - h5outOfMemory(env, "H5Iget_name: malloc failed"); - } /* end if */ - else { - size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size); - if (size < 0) { - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); - } - HDfree(aName); - } - } + ssize_t size = -1; + jstring str; + char *aName = NULL; + + UNUSED(clss); + + if (buf_size < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Iget_name_long: buf_size < 0"); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name_long: malloc failed"); + + if ((size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + aName[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (aName) + HDfree(aName); + return (jlong)size; } /* end Java_hdf_hdf5lib_H5_H5Iget_1name */ @@ -95,33 +100,30 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Iget_1name (JNIEnv *env, jclass clss, jlong obj_id) { - char *aName; jstring str = NULL; - ssize_t buf_size; - - /* get the length of the name */ - buf_size = H5Iget_name((hid_t)obj_id, NULL, 0); - - if (buf_size <= 0) { - h5badArgument(env, "H5Iget_name: buf_size <= 0"); - } /* end if */ - else { - buf_size++; /* add extra space for the null terminator */ - aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (aName == NULL) { - h5outOfMemory(env, "H5Iget_name: malloc failed"); - } /* end if */ - else { - buf_size = H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size); - if (buf_size < 0) { - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - } - HDfree(aName); - } - } + ssize_t buf_size = -1; + char *aName = NULL; + + UNUSED(clss); + + /* Get the length of the name */ + if ((buf_size = H5Iget_name((hid_t)obj_id, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Iget_name: malloc failed"); + + if (H5Iget_name((hid_t)obj_id, aName, (size_t)buf_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + aName[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (aName) + HDfree(aName); + return str; } /* end Java_hdf_hdf5lib_H5_H5Iget_1name */ @@ -134,12 +136,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1ref (JNIEnv *env, jclass clss, jlong obj_id) { - int retVal = -1; + int retVal = FAIL; + + UNUSED(clss); - retVal = H5Iget_ref((hid_t)obj_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Iget_ref((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Iget_1ref */ @@ -152,12 +156,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1ref (JNIEnv *env, jclass clss, jlong obj_id) { - int retVal = -1; + int retVal = FAIL; + + UNUSED(clss); - retVal = H5Iinc_ref((hid_t)obj_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Iinc_ref((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Iinc_1ref */ @@ -170,12 +176,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1ref (JNIEnv *env, jclass clss, jlong obj_id) { - int retVal = -1; + int retVal = FAIL; - retVal = H5Idec_ref((hid_t)obj_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Idec_ref((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Idec_1ref */ @@ -189,12 +197,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Iget_1file_1id (JNIEnv *env, jclass clss, jlong obj_id) { - hid_t file_id = -1; + hid_t file_id = H5I_INVALID_HID; + + UNUSED(clss); - file_id = H5Iget_file_id((hid_t)obj_id); - if (file_id < 0) - h5libraryError(env); + if ((file_id = H5Iget_file_id((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong) file_id; } /* end Java_hdf_hdf5lib_H5_H5Iget_1file_1id */ @@ -207,12 +217,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iget_1type_1ref (JNIEnv *env, jclass clss, jint type) { - int retVal = -1; + int retVal = FAIL; - retVal = H5Iget_type_ref((H5I_type_t)type); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Iget_type_ref((H5I_type_t)type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Iget_1type_1ref */ @@ -225,12 +237,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Idec_1type_1ref (JNIEnv *env, jclass clss, jint type) { - int retVal = -1; + int retVal = FAIL; + + UNUSED(clss); - retVal = H5Idec_type_ref((H5I_type_t)type); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Idec_type_ref((H5I_type_t)type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Idec_1type_1ref */ @@ -243,12 +257,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref (JNIEnv *env, jclass clss, jint type) { - int retVal = -1; + int retVal = FAIL; - retVal = H5Iinc_type_ref((H5I_type_t)type); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Iinc_type_ref((H5I_type_t)type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Iinc_1type_1ref */ @@ -261,11 +277,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Inmembers (JNIEnv *env, jclass clss, jint type) { - hsize_t num_members; + hsize_t num_members = 0; + + UNUSED(clss); if (H5Inmembers((H5I_type_t)type, &num_members) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)num_members; } /* end Java_hdf_hdf5lib_H5_H5Inmembers */ @@ -280,12 +299,14 @@ Java_hdf_hdf5lib_H5_H5Iis_1valid { htri_t bval = JNI_FALSE; - bval = H5Iis_valid((hid_t)obj_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + if ((bval = H5Iis_valid((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Iis_1valid */ /* @@ -299,12 +320,14 @@ Java_hdf_hdf5lib_H5_H5Itype_1exists { htri_t bval = JNI_FALSE; - bval = H5Itype_exists((H5I_type_t)type); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Itype_exists((H5I_type_t)type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; +done: return (jboolean)bval; } /* end else Java_hdf_hdf5lib_H5_H5Itype_1exists */ @@ -317,8 +340,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Iclear_1type (JNIEnv *env, jclass clss, jint type, jboolean force) { - if (H5Iclear_type((H5I_type_t)type, (hbool_t)force) < 0) - h5libraryError(env); + UNUSED(clss); + + if (H5Iclear_type((H5I_type_t)type, (hbool_t)force) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Iclear_1type */ /* @@ -330,8 +358,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Idestroy_1type (JNIEnv *env, jclass clss, jint type) { - if (H5Idestroy_type((H5I_type_t)type) < 0) - h5libraryError(env); + UNUSED(clss); + + if (H5Idestroy_type((H5I_type_t)type) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Idestroy_1type */ #ifdef __cplusplus diff --git a/java/src/jni/h5jni.h b/java/src/jni/h5jni.h index 2970e14..4a94180 100644 --- a/java/src/jni/h5jni.h +++ b/java/src/jni/h5jni.h @@ -27,147 +27,299 @@ #ifdef __cplusplus #define ENVPTR (env) - #define ENVPAR #define ENVONLY #define CBENVPTR (cbenv) - #define CBENVPAR + #define CBENVONLY #define JVMPTR (jvm) #define JVMPAR - #define JVMPAR2 #else /* __cplusplus */ #define ENVPTR (*env) - #define ENVPAR env, #define ENVONLY env #define CBENVPTR (*cbenv) - #define CBENVPAR cbenv, + #define CBENVONLY cbenv #define JVMPTR (*jvm) #define JVMPAR jvm - #define JVMPAR2 jvm, #endif /* __cplusplus */ +/* + * Used to silence compiler when a particular + * function parameter is not used. + */ +#define UNUSED(o) (void) o + /* Macros for class access */ /* Calling code must define ret_obj as jobject */ -#define CALL_CONSTRUCTOR(classname,classsig,args) { \ - jclass cls; \ - jmethodID constructor; \ - cls = ENVPTR->FindClass(ENVPAR (classname)); \ - if (cls == 0) { \ - h5JNIFatalError(env, "JNI error: GetObjectClass\n"); \ - ret_obj = NULL; \ - } \ - constructor = ENVPTR->GetMethodID(ENVPAR cls, "", (classsig)); \ - if (constructor == 0) { \ - h5JNIFatalError(env, "JNI error: GetMethodID failed\n"); \ - ret_obj = NULL; \ - } \ - ret_obj = ENVPTR->NewObjectA(ENVPAR cls, constructor, (args)); \ +#define CALL_CONSTRUCTOR(env, classname, classsig, args, ret_obj) \ +{ \ + jmethodID constructor; \ + jclass cls; \ + \ + if (NULL == (cls = ENVPTR->FindClass(env, (classname)))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, "JNI error: GetObjectClass"); \ + } \ + if (NULL == (constructor = ENVPTR->GetMethodID(ENVONLY, cls, "", (classsig)))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, "JNI error: GetMethodID failed"); \ + } \ + if (NULL == (ret_obj = ENVPTR->NewObjectA(ENVONLY, cls, constructor, (args)))) { \ + CHECK_JNI_EXCEPTION(env, JNI_FALSE); \ + } \ +} + +/* + * Macros for pinning/unpinning objects. + */ +#define PIN_BYTE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetByteArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_BYTE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jbyte *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_BYTE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseByteArrayElements(env, pinnedArray, (jbyte *) bufToRelease, freeMode); \ +} + +#define PIN_SHORT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetShortArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_SHORT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jshort *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_SHORT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseShortArrayElements(env, pinnedArray, (jshort *) bufToRelease, freeMode); \ +} + +#define PIN_INT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetIntArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_INT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jint *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_INT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseIntArrayElements(env, pinnedArray, (jint *) bufToRelease, freeMode); \ +} + +#define PIN_LONG_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetLongArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_LONG_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jlong *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_LONG_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseLongArrayElements(env, pinnedArray, (jlong *) bufToRelease, freeMode); \ +} + +#define PIN_FLOAT_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetFloatArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_FLOAT_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jfloat *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_FLOAT_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseFloatArrayElements(env, pinnedArray, (jfloat *) bufToRelease, freeMode); \ +} + +#define PIN_DOUBLE_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetDoubleArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_DOUBLE_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jdouble *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_DOUBLE_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseDoubleArrayElements(env, pinnedArray, (jdouble *) bufToRelease, freeMode); \ +} + +#define PIN_BOOL_ARRAY(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = ENVPTR->GetBooleanArrayElements(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define PIN_BOOL_ARRAY_CRITICAL(env, arrayToPin, outBuf, isCopy, failErrMsg) \ +{ \ + if (NULL == (outBuf = (jboolean *) ENVPTR->GetPrimitiveArrayCritical(env, arrayToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ } +#define UNPIN_BOOL_ARRAY(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleaseBooleanArrayElements(env, pinnedArray, (jboolean *) bufToRelease, freeMode); \ +} + +#define UNPIN_ARRAY_CRITICAL(env, pinnedArray, bufToRelease, freeMode) \ +{ \ + ENVPTR->ReleasePrimitiveArrayCritical(env, pinnedArray, bufToRelease, freeMode); \ +} /* Macros for string access */ -#define PIN_JAVA_STRING(javastr,localstr) { \ - jboolean isCopy; \ - (localstr) = NULL; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - } \ - else { \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - } \ - } \ -} - -#define UNPIN_JAVA_STRING(javastr,localstr) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ -} - -#define PIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \ - jboolean isCopy; \ - (localstr) = NULL; \ - (local2str) = NULL; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - } \ - else if ((java2str) == NULL) { \ - h5nullArgument(env, "second java string is NULL"); \ - } \ - else { \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - } \ - else { \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - } \ - } \ - } \ -} - -#define UNPIN_JAVA_STRING_TWO(javastr,localstr,java2str,local2str) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ -} - -#define PIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \ - jboolean isCopy; \ - (localstr) = NULL; \ - (local2str) = NULL; \ - (local3str) = NULL; \ - if ((javastr) == NULL) { \ - h5nullArgument(env, "java string is NULL"); \ - } \ - else if ((java2str) == NULL) { \ - h5nullArgument(env, "second java string is NULL"); \ - } \ - else if ((java3str) == NULL) { \ - h5nullArgument(env, "third java string is NULL"); \ - } \ - else { \ - (localstr) = ENVPTR->GetStringUTFChars(ENVPAR (javastr), &isCopy); \ - if ((localstr) == NULL) { \ - h5JNIFatalError(env, "local c string is not pinned"); \ - } \ - else { \ - (local2str) = ENVPTR->GetStringUTFChars(ENVPAR (java2str), &isCopy); \ - if ((local2str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - h5JNIFatalError(env, "second local c string is not pinned"); \ - } \ - else { \ - (local3str) = ENVPTR->GetStringUTFChars(ENVPAR (java3str), &isCopy); \ - if ((local3str) == NULL) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ - h5JNIFatalError(env, "third local c string is not pinned"); \ - } \ - } \ - } \ - } \ -} - -#define UNPIN_JAVA_STRING_THREE(javastr,localstr,java2str,local2str,java3str,local3str) { \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (javastr), (localstr)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java2str), (local2str)); \ - ENVPTR->ReleaseStringUTFChars(ENVPAR (java3str), (local3str)); \ +#define PIN_JAVA_STRING(env, stringToPin, outString, isCopy, failErrMsg) \ +{ \ + if (NULL == (outString = ENVPTR->GetStringUTFChars(env, stringToPin, isCopy))) { \ + CHECK_JNI_EXCEPTION(env, JNI_TRUE); \ + H5_JNI_FATAL_ERROR(env, failErrMsg); \ + } \ +} + +#define UNPIN_JAVA_STRING(env, pinnedString, stringToRelease) \ +{ \ + ENVPTR->ReleaseStringUTFChars(env, pinnedString, stringToRelease); \ +} + +/* + * Macro to check for a JNI exception after a JNI method is called. + * If an exception occurred, the value of 'clearException' will determine + * whether or not the exception will be cleared in order for the native + * method to do its own error handling. + * + * If the exception does not get cleared, this macro will skip to the + * cleanup+return section of the native method, since at that point + * cleaning up and returning is the only safe thing that can be done. + */ +#define CHECK_JNI_EXCEPTION(env, clearException) \ +{ \ + if (JNI_TRUE == (*env)->ExceptionCheck(env)) { \ + if (JNI_TRUE == clearException) \ + (*env)->ExceptionClear(env); \ + else \ + goto done; \ + } \ } #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -extern jboolean h5JNIFatalError(JNIEnv *, const char *); -extern jboolean h5nullArgument(JNIEnv *, const char *); -extern jboolean h5badArgument (JNIEnv *, const char *); -extern jboolean h5outOfMemory (JNIEnv *, const char *); -extern jboolean h5libraryError(JNIEnv *env ); -extern jboolean h5raiseException(JNIEnv *, const char *, const char *); +extern jboolean h5JNIFatalError(JNIEnv *env, const char *); +extern jboolean h5nullArgument(JNIEnv *env, const char *); +extern jboolean h5badArgument(JNIEnv *env, const char *); +extern jboolean h5outOfMemory(JNIEnv *env, const char *); +extern jboolean h5libraryError(JNIEnv *env); +extern jboolean h5raiseException(JNIEnv *env, const char *, const char *); extern jboolean h5unimplemented( JNIEnv *env, const char *functName); +/* + * The following macros are to facilitate immediate cleanup+return + * from a native JNI method when an exception is to be thrown. + * Since, in general, the "cleanup" methods are the only safe JNI + * methods to call once an exception has occurred, we want to immediately + * cleanup and return instead of letting the native method continue. + * + * Note that a native method can clear the exception when one occurs and + * then do its own error handling, but we instead opt to immediately return. + */ +#define H5_JNI_FATAL_ERROR(env, message) \ +{ \ + h5JNIFatalError(env, message); \ + goto done; \ +} + +#define H5_NULL_ARGUMENT_ERROR(env, message) \ +{ \ + h5nullArgument(env, message); \ + goto done; \ +} + +#define H5_BAD_ARGUMENT_ERROR(env, message) \ +{ \ + h5badArgument(env, message); \ + goto done; \ +} + +#define H5_OUT_OF_MEMORY_ERROR(env, message) \ +{ \ + h5outOfMemory(env, message); \ + goto done; \ +} + +#define H5_LIBRARY_ERROR(env) \ +{ \ + h5libraryError(env); \ + goto done; \ +} + +#define H5_RAISE_EXCEPTION(env, message, exception) \ +{ \ + h5raiseException(env, message, exception); \ + goto done; \ +} + +#define H5_UNIMPLEMENTED(env, message) \ +{ \ + h5unimplemented(env, message); \ + goto done; \ +} + /* implemented at H5.c */ extern jint get_enum_value(JNIEnv *env, jobject enum_obj); extern jobject get_enum_object(JNIEnv *env, const char* enum_class_name, diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index e1ec3bd..5999270 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -27,6 +27,9 @@ extern "C" { #include "h5jni.h" #include "h5lImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; typedef struct _cb_wrapper { @@ -50,19 +53,23 @@ Java_hdf_hdf5lib_H5_H5Lcopy (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lCurName; - const char *lDstName; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (lCurName != NULL && lDstName != NULL) { - status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcopy: src name not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcopy: dest name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Lcopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (lDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, lDstName); + if (lCurName) + UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); } /* end Java_hdf_hdf5lib_H5_H5Lcopy */ /* @@ -75,20 +82,27 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1external (JNIEnv *env, jclass clss, jstring file_name, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lFileName; - const char *lCurName; - const char *lDstName; - - PIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); - if (lFileName != NULL && lCurName != NULL && lDstName != NULL) { - status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); - - UNPIN_JAVA_STRING_THREE(file_name, lFileName, cur_name, lCurName, dst_name, lDstName); - - if (status < 0) - h5libraryError(env); - } + const char *lFileName = NULL; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, file_name, lFileName, NULL, "H5Lcreate_external: file name not pinned"); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_external: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_external: link name not pinned"); + + if ((status = H5Lcreate_external(lFileName, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (lDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, lDstName); + if (lCurName) + UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); + if (lFileName) + UNPIN_JAVA_STRING(ENVONLY, file_name, lFileName); } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1external */ /* @@ -101,19 +115,23 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1hard (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lCurName; - const char *lDstName; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (lCurName != NULL && lDstName != NULL) { - status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_hard: object name not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_hard: link name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Lcreate_hard((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (lDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, lDstName); + if (lCurName) + UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1hard */ /* @@ -126,19 +144,23 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1soft (JNIEnv *env, jclass clss, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lCurName; - const char *lDstName; + const char *linkTarget = NULL; + const char *linkName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (lCurName != NULL && lDstName != NULL) { - status = H5Lcreate_soft(lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, cur_name, linkTarget, NULL, "H5Lcreate_soft: link target not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, linkName, NULL, "H5Lcreate_soft: link name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Lcreate_soft(linkTarget, (hid_t)dst_loc_id, linkName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (linkName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, linkName); + if (linkTarget) + UNPIN_JAVA_STRING(ENVONLY, cur_name, linkTarget); } /* end Java_hdf_hdf5lib_H5_H5Lcreate_1soft */ /* @@ -150,18 +172,19 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Ldelete (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - herr_t status = -1; - const char *lName; + const char *linkName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Ldelete((hid_t)loc_id, lName, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, lName); + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Ldelete: link name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Ldelete((hid_t)loc_id, linkName, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (linkName) + UNPIN_JAVA_STRING(ENVONLY, name, linkName); } /* end Java_hdf_hdf5lib_H5_H5Ldelete */ /* @@ -174,19 +197,20 @@ Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) { + const char *groupName = NULL; hsize_t n = (hsize_t)link_n; - herr_t status; - const char *lName; + herr_t status = FAIL; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Ldelete_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, lName); + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Ldelete_by_idx: group name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Ldelete_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (groupName) + UNPIN_JAVA_STRING(ENVONLY, name, groupName); } /* end Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx */ /* @@ -198,20 +222,21 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Lexists (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - htri_t bval = JNI_FALSE; - const char *lName; + const char *linkName = NULL; + htri_t bval = JNI_FALSE; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - bval = H5Lexists((hid_t)loc_id, lName, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, lName); + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lexists: link name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5Lexists((hid_t)loc_id, linkName, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (linkName) + UNPIN_JAVA_STRING(ENVONLY, name, linkName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Lexists */ @@ -225,33 +250,31 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Lget_1info (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - jobject ret_obj = NULL; - jvalue args[5]; - herr_t status; H5L_info_t infobuf; - const char *lName; - - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Lget_info((hid_t)loc_id, lName, &infobuf, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - if(infobuf.type==0) - args[4].j = (jlong)infobuf.u.address; - else - args[4].j = (jlong)infobuf.u.val_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); - } /* end else */ - } /* end if */ + const char *linkName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_info: link name not pinned"); + + if ((status = H5Lget_info((hid_t)loc_id, linkName, &infobuf, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].j = (infobuf.type == H5L_TYPE_HARD) ? (jlong) infobuf.u.address : (jlong) infobuf.u.val_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + +done: + if (linkName) + UNPIN_JAVA_STRING(ENVONLY, name, linkName); + return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Lget_1info */ @@ -265,33 +288,31 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) { - jobject ret_obj = NULL; - jvalue args[5]; - herr_t status; H5L_info_t infobuf; - const char *lName; - - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = infobuf.type; - args[1].z = infobuf.corder_valid; - args[2].j = infobuf.corder; - args[3].i = infobuf.cset; - if(infobuf.type==0) - args[4].j = (jlong)infobuf.u.address; - else - args[4].j = (jlong)infobuf.u.val_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args); - } /* end els */ - } + const char *groupName = NULL; + jvalue args[5]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_info_by_idx: group name not pinned"); + + if ((status = H5Lget_info_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = infobuf.type; + args[1].z = infobuf.corder_valid; + args[2].j = infobuf.corder; + args[3].i = infobuf.cset; + args[4].j = (infobuf.type == H5L_TYPE_HARD) ? (jlong) infobuf.u.address : (jlong) infobuf.u.val_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5L_info_t", "(IZJIJ)V", args, ret_obj); + +done: + if (groupName) + UNPIN_JAVA_STRING(ENVONLY, name, groupName); + return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx */ @@ -305,43 +326,35 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong access_id) { - jlong status_size; + const char *groupName = NULL; jstring str = NULL; - size_t buf_size; - const char *lName; - char *lValue; - - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - /* get the length of the link name */ - status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)NULL, (size_t)0, H5P_DEFAULT); - if(status_size < 0) { - h5libraryError(env); - } /* end if */ - else { - buf_size = (size_t)status_size + 1;/* add extra space for the null terminator */ - - lValue = (char*)HDmalloc(sizeof(char) * buf_size); - if (lValue == NULL) { - h5outOfMemory(env, "H5Lget_name_by_idx: malloc failed "); - } /* end if */ - else { - status_size = H5Lget_name_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char*)lValue, (size_t)buf_size, (hid_t)access_id); - - if (status_size < 0) { - HDfree(lValue); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR lValue); - HDfree(lValue); - if (str == NULL) - h5JNIFatalError(env, "H5Lget_name_by_idx: return string not created"); - } /* end else */ - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, lName); - } + ssize_t status_size = -1; + char *linkName = NULL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_name_by_idx: group name not pinned"); + + /* Get the length of the link name */ + if ((status_size = H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)NULL, (size_t)0, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* add extra space for the null terminator */ + if (NULL == (linkName = (char *) HDmalloc(sizeof(char) * (size_t)status_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_name_by_idx: failed to allocate buffer for link name"); + + if ((H5Lget_name_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (char *)linkName, (size_t)status_size + 1, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + linkName[status_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, linkName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (linkName) + HDfree(linkName); + if (groupName) + UNPIN_JAVA_STRING(ENVONLY, name, groupName); return str; } /* end Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx */ @@ -355,80 +368,80 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lget_1value (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jobjectArray link_value, jlong access_id) { - size_t buf_size; - herr_t status; H5L_info_t infobuf; - const char *lName; - char *lValue; - const char *file_name; - const char *obj_name; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *linkName = NULL; jstring str; + herr_t status; + char *linkValue = NULL; + + UNUSED(clss); + + infobuf.type = H5L_TYPE_ERROR; + + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_value: link name not pinned"); + + /* Get the length of the link value */ + if ((status = H5Lget_info((hid_t)loc_id, linkName, &infobuf, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5L_TYPE_HARD == infobuf.type) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: hard links are unsupported"); + + if (NULL == (linkValue = (char *) HDmalloc(sizeof(char) * infobuf.u.val_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: failed to allocate buffer for link value"); + + if ((status = H5Lget_val((hid_t)loc_id, linkName, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + linkValue[infobuf.u.val_size] = '\0'; + + switch (infobuf.type) { + case H5L_TYPE_SOFT: + { + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, linkValue))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - infobuf.type = -1; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - /* get the length of the link val */ - status = H5Lget_info((hid_t)loc_id, lName, &infobuf, H5P_DEFAULT); - if(status < 0) { - h5libraryError(env); - } /* end if */ - else { - buf_size = infobuf.u.val_size + 1;/* add extra space for the null terminator */ - - if(infobuf.type == H5L_TYPE_HARD) { - h5JNIFatalError(env, "H5Lget_val: link is hard type"); - } /* end if */ - else { - lValue = (char*)HDmalloc(sizeof(char) * buf_size); - if (lValue == NULL) { - h5outOfMemory(env, "H5Lget_val: malloc failed"); - } /* end if */ - else { - status = H5Lget_val((hid_t)loc_id, lName, (void*)lValue, buf_size, (hid_t)access_id); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else if(infobuf.type == H5L_TYPE_EXTERNAL) { - status = H5Lunpack_elink_val(lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, &file_name, &obj_name); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR obj_name); - if (str == NULL) { - h5JNIFatalError(env, "H5Lget_val: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - - str = ENVPTR->NewStringUTF(ENVPAR file_name); - if (str == NULL) { - h5JNIFatalError(env, "H5Lget_val: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR lValue); - if (str == NULL) { - /* exception -- fatal JNI error */ - h5JNIFatalError(env, "H5Lget_val: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - } /* end else */ - } /* end else */ - HDfree(lValue); - } /* end else */ - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, lName); + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + case H5L_TYPE_EXTERNAL: + { + if ((status = H5Lunpack_elink_val(linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, &file_name, &obj_name)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, obj_name))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file_name))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 1, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + case H5L_TYPE_HARD: + default: + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val: invalid link type"); + break; } +done: + if (linkValue) + HDfree(linkValue); + if (linkName) + UNPIN_JAVA_STRING(ENVONLY, name, linkName); + return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val */ @@ -442,78 +455,83 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jobjectArray link_value, jlong access_id) { - herr_t status; - size_t buf_size; H5L_info_t infobuf; - const char *lName; - void *lValue; - const char *file_name; - const char *obj_name; + const char *file_name = NULL; + const char *obj_name = NULL; + const char *grpName = NULL; jstring str; + herr_t status; + void *linkValue = NULL; + + UNUSED(clss); + + infobuf.type = H5L_TYPE_ERROR; + + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lget_val_by_idx: group name not pinned"); + + /* Get the length of the link value */ + if ((status = H5Lget_info_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5L_TYPE_HARD == infobuf.type) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: hard links are unsupported") + + if (!infobuf.u.val_size) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (linkValue = (void *) HDmalloc(infobuf.u.val_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: failed to allocate buffer for link value"); + + if ((status = H5Lget_val_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void *)linkValue, infobuf.u.val_size + 1, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + ((char *) linkValue)[infobuf.u.val_size] = '\0'; + + switch (infobuf.type) { + case H5L_TYPE_SOFT: + { + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, (char *)linkValue))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + case H5L_TYPE_EXTERNAL: + { + if ((status = H5Lunpack_elink_val((char *)linkValue, (size_t)infobuf.u.val_size, (unsigned *)NULL, (const char **)&file_name, (const char**)&obj_name)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, obj_name))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file_name))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, link_value, 1, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } - infobuf.type = -1; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - /* get the length of the link valuee */ - status = H5Lget_info_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id); - if(status < 0) { - h5libraryError(env); - } /* end if */ - else { - buf_size = infobuf.u.val_size; - if(buf_size == 0) { - h5libraryError(env); - } /* end if */ - else { - lValue = (void*)HDmalloc(buf_size); - if (lValue == NULL) { - h5outOfMemory(env, "H5Lget_val_by_idx: malloc failed "); - } /* end if */ - else { - status = H5Lget_val_by_idx((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (void*)lValue, (size_t)buf_size, (hid_t)access_id); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else if(infobuf.type == H5L_TYPE_EXTERNAL) { - status = H5Lunpack_elink_val((char*)lValue, (size_t)infobuf.u.val_size, (unsigned*)NULL, (const char**)&file_name, (const char**)&obj_name); - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR obj_name); - if (str == NULL) { - h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - - str = ENVPTR->NewStringUTF(ENVPAR file_name); - if (str == NULL) { - h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 1, str); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR (char *)lValue); - if (str == NULL) { - h5JNIFatalError(env, "H5Lget_val_by_idx: return string not created"); - } /* end if */ - else { - ENVPTR->SetObjectArrayElement(ENVPAR link_value, 0, str); - } /* end else */ - } /* end else */ - HDfree(lValue); - } /* end else */ - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, lName); + case H5L_TYPE_ERROR: + case H5L_TYPE_MAX: + case H5L_TYPE_HARD: + default: + H5_JNI_FATAL_ERROR(ENVONLY, "H5Lget_val_by_idx: invalid link type"); + break; } +done: + if (linkValue) + HDfree(linkValue); + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); + return infobuf.type; } /* end Java_hdf_hdf5lib_H5_H5Lget_1val_1by_1idx */ @@ -527,73 +545,81 @@ Java_hdf_hdf5lib_H5_H5Lmove (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lCurName; - const char *lDstName; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (lCurName != NULL && lDstName != NULL) { - status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lmove: src name not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lmove: dest name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Lmove((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: + if (lDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, lDstName); + if (lCurName) + UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); } /* end Java_hdf_hdf5lib_H5_H5Lmove */ static herr_t H5L_iterate_cb (hid_t g_id, const char *name, const H5L_info_t *info, void *cb_data) { - JNIEnv *cbenv; - jint status; - jclass cls; - jmethodID mid; - jstring str; - jmethodID constructor; - jvalue args[5]; - jobject cb_info_t = NULL; cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_t;)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - - args[0].i = info->type; - args[1].z = info->corder_valid; - args[2].j = info->corder; - args[3].i = info->cset; - if(info->type==0) - args[4].j = (jlong)info->u.address; - else - args[4].j = (jlong)info->u.val_size; - // get a reference to your class if you don't have it already - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5L_info_t"); - if (cls != 0) { - // get a reference to the constructor; the name is - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(IZJIJ)V"); - if (constructor != 0) { - cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (cb_info_t == NULL) { - printf("FATAL ERROR: hdf/hdf5lib/structs/H5L_info_t: Creation failed\n"); - } - else { - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); - } - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return status; + jmethodID constructor, mid; + jobject cb_info_t = NULL; + jobject visit_callback = wrapper->visit_callback; + jstring str; + JNIEnv *cbenv = NULL; + jclass cls; + jvalue args[5]; + void *op_data = (void *)wrapper->op_data; + jint status; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5L_iterate_cb: failed to attach current thread to JVM"); + } + + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[0].i = info->type; + args[1].z = info->corder_valid; + args[2].j = info->corder; + args[3].i = info->cset; + args[4].j = (info->type == H5L_TYPE_HARD) ? (jlong)info->u.address : (jlong)info->u.val_size; + + /* Get a reference to your class if you don't have it already */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5L_info_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* Get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(IZJIJ)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("FATAL ERROR: hdf/hdf5lib/structs/H5L_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); + + return (herr_t)status; } /* end H5L_iterate_cb */ /* @@ -606,20 +632,23 @@ Java_hdf_hdf5lib_H5_H5Lvisit (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jobject callback_op, jobject op_data) { - herr_t status = -1; - cb_wrapper wrapper = {callback_op, op_data}; + cb_wrapper wrapper = { callback_op, op_data }; + herr_t status = FAIL; + + UNUSED(clss); - ENVPTR->GetJavaVM(ENVPAR &jvm); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Lvisit: op_data or callback_op is NULL"); - } /* end if */ - else { - status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper); - if (status < 0) - h5libraryError(env); - } /* end else */ + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit: callback_op is NULL"); + if ((status = H5Lvisit((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return status; } /* end Java_hdf_hdf5lib_H5_H5Lvisit */ @@ -633,26 +662,28 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, jobject callback_op, jobject op_data, jlong access_id) { - herr_t status = -1; - const char *lName; - cb_wrapper wrapper = {callback_op, op_data}; + cb_wrapper wrapper = { callback_op, op_data }; + const char *grpName = NULL; + herr_t status = FAIL; - ENVPTR->GetJavaVM(ENVPAR &jvm); + UNUSED(clss); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Lvisit_by_name: op_data or callback_op is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Lvisit_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - UNPIN_JAVA_STRING(name, lName); + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit_by_name: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit_by_name: callback_op is NULL"); - if (status < 0) - h5libraryError(env); - } - } /* end else */ + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lvisit_by_name: group name not pinned"); + + if ((status = H5Lvisit_by_name((hid_t)grp_id, grpName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); return status; } /* end Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name */ @@ -667,22 +698,24 @@ Java_hdf_hdf5lib_H5_H5Literate (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jlong idx, jobject callback_op, jobject op_data) { - hsize_t start_idx = (hsize_t)idx; - herr_t status = -1; - cb_wrapper wrapper = {callback_op, op_data}; + cb_wrapper wrapper = { callback_op, op_data }; + hsize_t start_idx = (hsize_t)idx; + herr_t status = FAIL; - ENVPTR->GetJavaVM(ENVPAR &jvm); + UNUSED(clss); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Literate: op_data or callback_op is NULL"); - } /* end if */ - else { - status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (status < 0) - h5libraryError(env); - } /* end else */ + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate: callback_op is NULL"); + if ((status = H5Literate((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t *)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return status; } /* end Java_hdf_hdf5lib_H5_H5Literate */ @@ -696,27 +729,29 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, jlong idx, jobject callback_op, jobject op_data, jlong access_id) { - hsize_t start_idx = (hsize_t)idx; - herr_t status = -1; - const char *lName; + cb_wrapper wrapper = { callback_op, op_data }; + const char *groupName = NULL; + hsize_t start_idx = (hsize_t)idx; + herr_t status = FAIL; - ENVPTR->GetJavaVM(ENVPAR &jvm); - cb_wrapper wrapper = {callback_op, op_data}; + UNUSED(clss); - if ((op_data == NULL) || (callback_op == NULL)) { - h5nullArgument(env, "H5Literate_by_name: op_data or callback_op is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Literate_by_name((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id); + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - UNPIN_JAVA_STRING(name, lName); + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate_by_name: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate_by_name: callback_op is NULL"); - if (status < 0) - h5libraryError(env); - } - } /* end else */ + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Literate_by_name: group name not pinned"); + + if ((status = H5Literate_by_name((hid_t)grp_id, groupName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t*)&start_idx, (H5L_iterate_t)H5L_iterate_cb, (void*)&wrapper, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (groupName) + UNPIN_JAVA_STRING(ENVONLY, name, groupName); return status; } /* end Java_hdf_hdf5lib_H5_H5Literate_1by_1name */ @@ -730,11 +765,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Lis_1registered (JNIEnv *env, jclass clss, jint link_cls_id) { - htri_t ret_val = H5Lis_registered((H5L_type_t)link_cls_id); + htri_t ret_val = FAIL; - if (ret_val < 0) - h5libraryError(env); + UNUSED(clss); + if ((ret_val = H5Lis_registered((H5L_type_t)link_cls_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (int)ret_val; } /* end Java_hdf_hdf5lib_H5_H5Lis_1registered */ @@ -747,8 +785,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Lunregister (JNIEnv *env, jclass clss, jint link_cls_id) { + UNUSED(clss); + if (H5Lunregister((H5L_type_t)link_cls_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Lunregister */ diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c index 1de505a..0b1a984 100644 --- a/java/src/jni/h5oImp.c +++ b/java/src/jni/h5oImp.c @@ -26,6 +26,9 @@ extern "C" { #include "h5jni.h" #include "h5oImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; typedef struct _cb_wrapper { @@ -48,18 +51,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist_id) { - hid_t status = -1; - const char *oName; + const char *objName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(name, oName); - if (oName != NULL) { - status = H5Oopen((hid_t)loc_id, oName, (hid_t)access_plist_id ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, oName); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oopen: object name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Oopen((hid_t)loc_id, objName, (hid_t)access_plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Oopen */ @@ -73,11 +77,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Oclose (JNIEnv *env, jclass clss, jlong object_id) { - herr_t retVal = H5Oclose((hid_t)object_id); + herr_t retVal = FAIL; - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Oclose((hid_t)object_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Oclose */ @@ -91,19 +98,23 @@ Java_hdf_hdf5lib_H5_H5Ocopy (JNIEnv *env, jclass clss, jlong cur_loc_id, jstring cur_name, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lCurName; - const char *lDstName; + const char *lCurName = NULL; + const char *lDstName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); - if (lCurName != NULL && lDstName != NULL) { - status = H5Ocopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING_TWO(cur_name, lCurName, dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Ocopy: src name not pinned"); + PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Ocopy: dest name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Ocopy((hid_t)cur_loc_id, lCurName, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (lDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, lDstName); + if (lCurName) + UNPIN_JAVA_STRING(ENVONLY, cur_name, lCurName); } /* end Java_hdf_hdf5lib_H5_H5Ocopy */ /* @@ -115,57 +126,61 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info (JNIEnv *env, jclass clss, jlong loc_id, jint fields) { - herr_t status = -1; - H5O_info_t infobuf; - jvalue args[12]; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; - jobject ret_obj = NULL; - - status = H5Oget_info2((hid_t)loc_id, &infobuf, (unsigned)fields); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = (jint)infobuf.hdr.version; - args[1].i = (jint)infobuf.hdr.nmesgs; - args[2].i = (jint)infobuf.hdr.nchunks; - args[3].i = (jint)infobuf.hdr.flags; - args[4].j = (jlong)infobuf.hdr.space.total; - args[5].j = (jlong)infobuf.hdr.space.meta; - args[6].j = (jlong)infobuf.hdr.space.mesg; - args[7].j = (jlong)infobuf.hdr.space.free; - args[8].j = (jlong)infobuf.hdr.mesg.present; - args[9].j = (jlong)infobuf.hdr.mesg.shared; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); - hdrinfobuf = ret_obj; - - args[0].j = (jlong)infobuf.meta_size.obj.index_size; - args[1].j = (jlong)infobuf.meta_size.obj.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf1 = ret_obj; - args[0].j = (jlong)infobuf.meta_size.attr.index_size; - args[1].j = (jlong)infobuf.meta_size.attr.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf2 = ret_obj; - - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); - } - + H5O_info_t infobuf; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jvalue args[12]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + if ((status = H5Oget_info2((hid_t)loc_id, &infobuf, (unsigned)fields)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args, ret_obj); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf1 = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + +done: return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Oget_1info */ @@ -178,62 +193,66 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint fields, jlong access_id) { - const char *lName; - herr_t status = -1; H5O_info_t infobuf; - jvalue args[12]; + const char *objName = NULL; jobject hdrinfobuf; jobject ihinfobuf1; jobject ihinfobuf2; + jvalue args[12]; + herr_t status = FAIL; jobject ret_obj = NULL; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Oget_info_by_name2((hid_t)loc_id, lName, &infobuf, (unsigned)fields, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = (jint)infobuf.hdr.version; - args[1].i = (jint)infobuf.hdr.nmesgs; - args[2].i = (jint)infobuf.hdr.nchunks; - args[3].i = (jint)infobuf.hdr.flags; - args[4].j = (jlong)infobuf.hdr.space.total; - args[5].j = (jlong)infobuf.hdr.space.meta; - args[6].j = (jlong)infobuf.hdr.space.mesg; - args[7].j = (jlong)infobuf.hdr.space.free; - args[8].j = (jlong)infobuf.hdr.mesg.present; - args[9].j = (jlong)infobuf.hdr.mesg.shared; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); - hdrinfobuf = ret_obj; - - args[0].j = (jlong)infobuf.meta_size.obj.index_size; - args[1].j = (jlong)infobuf.meta_size.obj.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf1 = ret_obj; - args[0].j = (jlong)infobuf.meta_size.attr.index_size; - args[1].j = (jlong)infobuf.meta_size.attr.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf2 = ret_obj; - - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); - } - } + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_info_by_name: object name not pinned"); + + if ((status = H5Oget_info_by_name2((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args, ret_obj); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf1 = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name */ @@ -248,62 +267,66 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jint fields, jlong access_id) { - const char *lName; - herr_t status; H5O_info_t infobuf; - jvalue args[12]; + const char *grpName = NULL; jobject hdrinfobuf; jobject ihinfobuf1; jobject ihinfobuf2; + jvalue args[12]; + herr_t status = FAIL; jobject ret_obj = NULL; - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Oget_info_by_idx2((hid_t)loc_id, lName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = (jint)infobuf.hdr.version; - args[1].i = (jint)infobuf.hdr.nmesgs; - args[2].i = (jint)infobuf.hdr.nchunks; - args[3].i = (jint)infobuf.hdr.flags; - args[4].j = (jlong)infobuf.hdr.space.total; - args[5].j = (jlong)infobuf.hdr.space.meta; - args[6].j = (jlong)infobuf.hdr.space.mesg; - args[7].j = (jlong)infobuf.hdr.space.free; - args[8].j = (jlong)infobuf.hdr.mesg.present; - args[9].j = (jlong)infobuf.hdr.mesg.shared; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args); - hdrinfobuf = ret_obj; - - args[0].j = (jlong)infobuf.meta_size.obj.index_size; - args[1].j = (jlong)infobuf.meta_size.obj.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf1 = ret_obj; - args[0].j = (jlong)infobuf.meta_size.attr.index_size; - args[1].j = (jlong)infobuf.meta_size.attr.heap_size; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args); - ihinfobuf2 = ret_obj; - - args[0].j = (jlong)infobuf.fileno; - args[1].j = (jlong)infobuf.addr; - args[2].i = infobuf.type; - args[3].i = (jint)infobuf.rc; - args[4].j = (jlong)infobuf.num_attrs; - args[5].j = infobuf.atime; - args[6].j = infobuf.mtime; - args[7].j = infobuf.ctime; - args[8].j = infobuf.btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args); - } - } + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_info_by_idx: group name not pinned"); + + if ((status = H5Oget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = (jint)infobuf.hdr.version; + args[1].i = (jint)infobuf.hdr.nmesgs; + args[2].i = (jint)infobuf.hdr.nchunks; + args[3].i = (jint)infobuf.hdr.flags; + args[4].j = (jlong)infobuf.hdr.space.total; + args[5].j = (jlong)infobuf.hdr.space.meta; + args[6].j = (jlong)infobuf.hdr.space.mesg; + args[7].j = (jlong)infobuf.hdr.space.free; + args[8].j = (jlong)infobuf.hdr.mesg.present; + args[9].j = (jlong)infobuf.hdr.mesg.shared; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t", "(IIIIJJJJJJ)V", args, ret_obj); + hdrinfobuf = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.obj.index_size; + args[1].j = (jlong)infobuf.meta_size.obj.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf1 = ret_obj; + + args[0].j = (jlong)infobuf.meta_size.attr.index_size; + args[1].j = (jlong)infobuf.meta_size.attr.heap_size; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t", "(JJ)V", args, ret_obj); + ihinfobuf2 = ret_obj; + + args[0].j = (jlong)infobuf.fileno; + args[1].j = (jlong)infobuf.addr; + args[2].i = infobuf.type; + args[3].i = (jint)infobuf.rc; + args[4].j = (jlong)infobuf.num_attrs; + args[5].j = infobuf.atime; + args[6].j = infobuf.mtime; + args[7].j = infobuf.ctime; + args[8].j = infobuf.btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5O_info_t", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V", args, ret_obj); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); return ret_obj; } /* end Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx */ @@ -318,130 +341,135 @@ Java_hdf_hdf5lib_H5_H5Olink (JNIEnv *env, jclass clss, jlong cur_loc_id, jlong dst_loc_id, jstring dst_name, jlong create_id, jlong access_id) { - herr_t status = -1; - const char *lDstName; + const char *linkDstName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(dst_name, lDstName); - if (lDstName != NULL) { - status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, lDstName, (hid_t)create_id, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(dst_name, lDstName); + PIN_JAVA_STRING(ENVONLY, dst_name, linkDstName, NULL, "H5Olink: link destination name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, linkDstName, (hid_t)create_id, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (linkDstName) + UNPIN_JAVA_STRING(ENVONLY, dst_name, linkDstName); } /* end Java_hdf_hdf5lib_H5_H5Olink */ static herr_t H5O_iterate_cb (hid_t g_id, const char *name, const H5O_info_t *info, void *cb_data) { - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - jmethodID constructor; - jvalue args[12]; - jobject hdrinfobuf; - jobject ihinfobuf1; - jobject ihinfobuf2; - jobject cb_info_t = NULL; cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; + jmethodID constructor, mid; + jobject cb_info_t = NULL; + jobject visit_callback = wrapper->visit_callback; + jobject hdrinfobuf; + jobject ihinfobuf1; + jobject ihinfobuf2; + jstring str; + JNIEnv *cbenv = NULL; + jclass cls; + jvalue args[12]; + void *op_data = (void *)wrapper->op_data; + jint status = FAIL; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5O_iterate_cb: failed to attach current thread to JVM"); + } + + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + args[0].i = (jint)info->hdr.version; + args[1].i = (jint)info->hdr.nmesgs; + args[2].i = (jint)info->hdr.nchunks; + args[3].i = (jint)info->hdr.flags; + args[4].j = (jlong)info->hdr.space.total; + args[5].j = (jlong)info->hdr.space.meta; + args[6].j = (jlong)info->hdr.space.mesg; + args[7].j = (jlong)info->hdr.space.free; + args[8].j = (jlong)info->hdr.mesg.present; + args[9].j = (jlong)info->hdr.mesg.shared; + + /* Get a reference to the H5_hdr_info_t class */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_hdr_info_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* Get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(IIIIJJJJJJ)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (hdrinfobuf = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_hdr_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + args[0].j = (jlong)info->meta_size.obj.index_size; + args[1].j = (jlong)info->meta_size.obj.heap_size; - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { - /* printf("JNI H5O_iterate_cb error: AttachCurrentThread failed\n"); */ + /* Get a reference to the H5_ih_info_t class */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5_ih_info_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* Get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(JJ)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (ihinfobuf1 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + args[0].j = (jlong)info->meta_size.attr.index_size; + args[1].j = (jlong)info->meta_size.attr.heap_size; + + if (NULL == (ihinfobuf2 = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + args[0].j = (jlong)info->fileno; + args[1].j = (jlong)info->addr; + args[2].i = info->type; + args[3].i = (jint)info->rc; + args[4].j = (jlong)info->num_attrs; + args[5].j = info->atime; + args[6].j = info->mtime; + args[7].j = info->ctime; + args[8].j = info->btime; + args[9].l = hdrinfobuf; + args[10].l = ihinfobuf1; + args[11].l = ihinfobuf2; + + /* Get a reference to the H5O_info_t class */ + if (NULL == (cls = CBENVPTR->FindClass(CBENVONLY, "hdf/hdf5lib/structs/H5O_info_t"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + /* Get a reference to the constructor; the name is */ + if (NULL == (constructor = CBENVPTR->GetMethodID(CBENVONLY, cls, "", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (cb_info_t = CBENVPTR->NewObjectA(CBENVONLY, cls, constructor, args))) { + HDprintf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n"); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, g_id, str, cb_info_t, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + +done: + if (cbenv) JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_t;)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - - args[0].i = (jint)info->hdr.version; - args[1].i = (jint)info->hdr.nmesgs; - args[2].i = (jint)info->hdr.nchunks; - args[3].i = (jint)info->hdr.flags; - args[4].j = (jlong)info->hdr.space.total; - args[5].j = (jlong)info->hdr.space.meta; - args[6].j = (jlong)info->hdr.space.mesg; - args[7].j = (jlong)info->hdr.space.free; - args[8].j = (jlong)info->hdr.mesg.present; - args[9].j = (jlong)info->hdr.mesg.shared; - // get a reference to the H5_hdr_info_t class - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5O_hdr_info_t"); - if (cls != 0) { - // get a reference to the constructor; the name is - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(IIIIJJJJJJ)V"); - if (constructor != 0) { - hdrinfobuf = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (hdrinfobuf == NULL) { - printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_hdr_info_t: Creation failed\n"); - } - else { - args[0].j = (jlong)info->meta_size.obj.index_size; - args[1].j = (jlong)info->meta_size.obj.heap_size; - // get a reference to the H5_ih_info_t class - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5_ih_info_t"); - if (cls != 0) { - // get a reference to the constructor; the name is - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(JJ)V"); - if (constructor != 0) { - ihinfobuf1 = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (ihinfobuf1 == NULL) { - printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); - } - else { - args[0].j = (jlong)info->meta_size.attr.index_size; - args[1].j = (jlong)info->meta_size.attr.heap_size; - ihinfobuf2 = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (ihinfobuf2 == NULL) { - printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5_ih_info_t: Creation failed\n"); - } - else { - args[0].j = (jlong)info->fileno; - args[1].j = (jlong)info->addr; - args[2].i = info->type; - args[3].i = (jint)info->rc; - args[4].j = (jlong)info->num_attrs; - args[5].j = info->atime; - args[6].j = info->mtime; - args[7].j = info->ctime; - args[8].j = info->btime; - args[9].l = hdrinfobuf; - args[10].l = ihinfobuf1; - args[11].l = ihinfobuf2; - // get a reference to the H5O_info_t class - cls = CBENVPTR->FindClass(CBENVPAR "hdf/hdf5lib/structs/H5O_info_t"); - if (cls != 0) { - // get a reference to the constructor; the name is - constructor = CBENVPTR->GetMethodID(CBENVPAR cls, "", "(JJIIJJJJJLhdf/hdf5lib/structs/H5O_hdr_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;Lhdf/hdf5lib/structs/H5_ih_info_t;)V"); - if (constructor != 0) { - cb_info_t = CBENVPTR->NewObjectA(CBENVPAR cls, constructor, args); - if (cb_info_t == NULL) { - printf("H5O_iterate_cb ERROR: hdf/hdf5lib/structs/H5O_info_t: Creation failed\n"); - } - else { - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, g_id, str, cb_info_t, op_data); - } - } - } - } - } - } - } - } - } - } - } - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return status; + return (herr_t)status; } /* end H5O_iterate_cb */ /* @@ -454,24 +482,23 @@ Java_hdf_hdf5lib_H5_H5Ovisit (JNIEnv *env, jclass clss, jlong grp_id, jint idx_type, jint order, jobject callback_op, jobject op_data, jint fields) { - herr_t status = -1; - cb_wrapper wrapper = {callback_op, op_data}; - - ENVPTR->GetJavaVM(ENVPAR &jvm); - - if (op_data == NULL) { - h5nullArgument(env, "H5Ovisit: op_data is NULL"); - } /* end if */ - else if (callback_op == NULL) { - h5nullArgument(env, "H5Ovisit: callback_op is NULL"); - } /* end if */ - else { - status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields); - - if (status < 0) - h5libraryError(env); - } + cb_wrapper wrapper = { callback_op, op_data }; + herr_t status = FAIL; + + UNUSED(clss); + + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit: callback_op is NULL"); + + if ((status = H5Ovisit2((hid_t)grp_id, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void *)&wrapper, (unsigned)fields)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return status; } /* end Java_hdf_hdf5lib_H5_H5Ovisit */ @@ -485,31 +512,28 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name (JNIEnv *env, jclass clss, jlong grp_id, jstring name, jint idx_type, jint order, jobject callback_op, jobject op_data, jint fields, jlong access_id) { - herr_t status = -1; - const char *lName; - cb_wrapper wrapper = {callback_op, op_data}; - - ENVPTR->GetJavaVM(ENVPAR &jvm); - - if (op_data == NULL) { - h5nullArgument(env, "H5Ovisit_by_name: op_data is NULL"); - return -1; - } /* end if */ - else if (callback_op == NULL) { - h5nullArgument(env, "H5Ovisit_by_name: callback_op is NULL"); - return -1; - } /* end if */ - else { - PIN_JAVA_STRING(name, lName); - if (lName != NULL) { - status = H5Ovisit_by_name2((hid_t)grp_id, lName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void*)&wrapper, (unsigned)fields, (hid_t)access_id); - - UNPIN_JAVA_STRING(name, lName); - - if (status < 0) - h5libraryError(env); - } - } + cb_wrapper wrapper = { callback_op, op_data }; + const char *objName = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit_by_name: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit_by_name: callback_op is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Ovisit_by_name: object name not pinned"); + + if ((status = H5Ovisit_by_name2((hid_t)grp_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (H5O_iterate_t)H5O_iterate_cb, (void *)&wrapper, (unsigned)fields, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return status; } /* end Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name */ @@ -523,24 +547,20 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oset_1comment (JNIEnv *env, jclass clss, jlong loc_id, jstring comment) { - herr_t status = -1; const char *oComment = NULL; - jboolean isCopy; + herr_t status = FAIL; - if (comment == NULL) { - status = H5Oset_comment((hid_t)loc_id, oComment); - } /* end if */ - else { - oComment = ENVPTR->GetStringUTFChars(ENVPAR comment, &isCopy); - if (oComment != NULL) { - status = H5Oset_comment((hid_t)loc_id, oComment); + UNUSED(clss); - ENVPTR->ReleaseStringUTFChars(ENVPAR comment, oComment); - } - } /* end else */ + if (NULL != comment) + PIN_JAVA_STRING(ENVONLY, comment, oComment, NULL, "H5Oset_comment: object comment not pinned"); - if (status < 0) - h5libraryError(env); + if ((status = H5Oset_comment((hid_t)loc_id, oComment)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (oComment) + UNPIN_JAVA_STRING(ENVONLY, comment, oComment); } /* end Java_hdf_hdf5lib_H5_H5Oset_1comment */ /* @@ -553,29 +573,26 @@ Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jstring comment, jlong access_id) { - herr_t status = -1; - const char *oName; - const char *oComment; - - PIN_JAVA_STRING(name, oName); - if (oName != NULL) { - if (comment == NULL) { - status = H5Oset_comment_by_name((hid_t)loc_id, oName, NULL, (hid_t)access_id); - } /* end if */ - else { - jboolean isCopy; - oComment = ENVPTR->GetStringUTFChars(ENVPAR comment, &isCopy); - if (oComment != NULL) { - status = H5Oset_comment_by_name((hid_t)loc_id, oName, oComment, (hid_t)access_id); - ENVPTR->ReleaseStringUTFChars(ENVPAR comment, oComment); - } /* end if */ - } /* end else */ - - UNPIN_JAVA_STRING(name, oName); - - if (status < 0) - h5libraryError(env); - } + const char *objName = NULL; + const char *objComment = NULL; + jboolean isCopy; + herr_t status = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oset_comment_by_name: object name not pinned"); + + if (NULL != comment) + PIN_JAVA_STRING(ENVONLY, comment, objComment, &isCopy, "H5Oset_comment_by_name: object comment not pinned"); + + if ((status = H5Oset_comment_by_name((hid_t)loc_id, objName, objComment, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (objComment) + UNPIN_JAVA_STRING(ENVONLY, comment, objComment); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); } /* end Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name */ /* @@ -587,39 +604,32 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment (JNIEnv *env, jclass clss, jlong loc_id) { - char *oComment; - ssize_t buf_size; - ssize_t status; jstring str = NULL; + ssize_t buf_size; + ssize_t status = -1; + char *oComment = NULL; + + UNUSED(clss); + + /* Get the length of the comment */ + if ((buf_size = H5Oget_comment((hid_t)loc_id, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (buf_size) { + if (NULL == (oComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment: failed to allocate object comment buffer"); + + if ((status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + oComment[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, oComment))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } - /* get the length of the comment */ - buf_size = H5Oget_comment((hid_t)loc_id, NULL, 0); - if (buf_size < 0) { - h5badArgument( env, "H5Oget_comment: buf_size < 0"); - } /* end if */ - else if (buf_size > 0) { - buf_size++; /* add extra space for the null terminator */ - oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); - if (oComment == NULL) { - /* exception -- out of memory */ - h5outOfMemory( env, "H5Oget_comment: malloc failed"); - } /* end if */ - else { - status = H5Oget_comment((hid_t)loc_id, oComment, (size_t)buf_size); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - /* may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR oComment); - if (str == NULL) { - h5JNIFatalError( env, "H5Oget_comment: return string not allocated"); - } /* end if */ - } /* end else */ - HDfree(oComment); - } - } /* end else if */ +done: + if (oComment) + HDfree(oComment); return (jstring)str; } /* end Java_hdf_hdf5lib_H5_H5Oget_1comment */ @@ -633,44 +643,38 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { - char *oComment; - const char *oName; + const char *objName = NULL; + jstring str = NULL; ssize_t buf_size; ssize_t status; - jstring str = NULL; + char *objComment = NULL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_comment_by_name: object name not pinned"); + + /* Get the length of the comment */ + if ((buf_size = H5Oget_comment_by_name((hid_t)loc_id, objName, NULL, 0, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (buf_size) { + if (NULL == (objComment = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Oget_comment_by_name: failed to allocate buffer for object comment"); + + if ((status = H5Oget_comment_by_name((hid_t)loc_id, objName, objComment, (size_t)buf_size + 1, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + objComment[buf_size] = '\0'; - PIN_JAVA_STRING(name, oName); - if (oName != NULL) { - /* get the length of the comment */ - buf_size = H5Oget_comment_by_name((hid_t)loc_id, oName, NULL, 0, (hid_t)access_id); - if (buf_size < 0) { - h5badArgument( env, "H5Oget_comment_by_name: buf_size < 0"); - } /* end if */ - else if (buf_size > 0) { - buf_size++; /* add extra space for the null terminator */ - oComment = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); - if (oComment == NULL) { - h5outOfMemory( env, "H5Oget_comment_by_name: malloc failed"); - } /* end if */ - else { - status = H5Oget_comment_by_name((hid_t)loc_id, oName, oComment, (size_t)buf_size, (hid_t)access_id); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - /* may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR oComment); - if (str == NULL) { - h5JNIFatalError( env, "H5Oget_comment_by_name: return string not allocated"); - } /* end if */ - } /* end else */ - HDfree(oComment); - } - } /* end if */ - UNPIN_JAVA_STRING(name, oName); + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, objComment))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } +done: + if (objComment) + HDfree(objComment); + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); + return (jstring)str; } /* end Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name */ @@ -683,20 +687,21 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5Oexists_1by_1name (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_id) { + const char *objName = NULL; htri_t bval = JNI_FALSE; - const char *oName; - PIN_JAVA_STRING(name, oName); - if (oName != NULL) { - bval = H5Oexists_by_name((hid_t)loc_id, oName, (hid_t)access_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, oName); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oexists_by_name: object name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5Oexists_by_name((hid_t)loc_id, objName, (hid_t)access_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (objName) + UNPIN_JAVA_STRING(ENVONLY, name, objName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Oexists_1by_1name */ @@ -710,8 +715,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Odecr_1refcount (JNIEnv *env, jclass clss, jlong object_id) { + UNUSED(clss); + if (H5Odecr_refcount((hid_t)object_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Odecr_1refcount */ /* @@ -723,8 +733,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oincr_1refcount (JNIEnv *env, jclass clss, jlong object_id) { + UNUSED(clss); + if (H5Oincr_refcount((hid_t)object_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Oincr_1refcount */ /* @@ -736,12 +751,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr (JNIEnv *env, jclass clss, jlong loc_id, jlong addr) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Oopen_by_addr((hid_t)loc_id, (haddr_t)addr ); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Oopen_by_addr((hid_t)loc_id, (haddr_t)addr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1addr */ @@ -755,18 +772,19 @@ Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jint index_field, jint order, jlong link_n, jlong lapl_id) { - hid_t retVal = -1; - const char *oName; + const char *grpName = NULL; + hid_t retVal = H5I_INVALID_HID; - PIN_JAVA_STRING(name, oName); - if (oName != NULL) { - retVal = H5Oopen_by_idx((hid_t)loc_id, oName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (hid_t)lapl_id ); + UNUSED(clss); - UNPIN_JAVA_STRING(name, oName); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oopen_by_idx: object name not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5Oopen_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (grpName) + UNPIN_JAVA_STRING(ENVONLY, name, grpName); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx */ @@ -780,8 +798,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Oflush (JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Oflush((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Oflush */ /* @@ -793,8 +816,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Orefresh (JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Orefresh((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Orefresh */ diff --git a/java/src/jni/h5pACPLImp.c b/java/src/jni/h5pACPLImp.c new file mode 100644 index 0000000..f6c14e1 --- /dev/null +++ b/java/src/jni/h5pACPLImp.c @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pACPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pACPLImp.h b/java/src/jni/h5pACPLImp.h new file mode 100644 index 0000000..194afc0 --- /dev/null +++ b/java/src/jni/h5pACPLImp.h @@ -0,0 +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 * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PACPL +#define _Included_hdf_hdf5lib_H5_H5PACPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PACPL */ diff --git a/java/src/jni/h5pDAPLImp.c b/java/src/jni/h5pDAPLImp.c new file mode 100644 index 0000000..0afbbd6 --- /dev/null +++ b/java/src/jni/h5pDAPLImp.c @@ -0,0 +1,322 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pDAPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +extern JavaVM *jvm; + +typedef struct _cb_wrapper { + jobject visit_callback; + jobject op_data; +} cb_wrapper; + +static herr_t H5D_append_cb(hid_t dataset_id, hsize_t *cur_dims, void *cb_data); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_cache + * Signature: (JJJD)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache + (JNIEnv *env, jclass clss, jlong dapl, jlong rdcc_nslots, + jlong rdcc_nbytes, jdouble rdcc_w0) +{ + UNUSED(clss); + + if (H5Pset_chunk_cache((hid_t)dapl, (size_t)rdcc_nslots, (size_t)rdcc_nbytes, (double) rdcc_w0) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_cache + * Signature: (J[J[J[D)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache + (JNIEnv *env, jclass clss, jlong dapl, jlongArray rdcc_nslots, + jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +{ + jboolean isCopy; + jdouble *w0Array = NULL; + jlong *rdcc_nslotsArray = NULL; + jlong *nbytesArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL != rdcc_w0) + PIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, &isCopy, "H5Pget_chunk_cache: rdcc_w0 array not pinned"); + if (NULL != rdcc_nslots) + PIN_LONG_ARRAY(ENVONLY, rdcc_nslots, rdcc_nslotsArray, &isCopy, "H5Pget_chunk_cache: rdcc_nslots array not pinned"); + if (NULL != rdcc_nbytes) + PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, "H5Pget_chunk_cache: nbytesArray array not pinned"); + + { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long rdcc_nslots_temp = *rdcc_nslotsArray; + long long nbytes_temp = *nbytesArray; + size_t rdcc_nslots_t = (size_t) rdcc_nslots_temp; + size_t nbytes_t = (size_t) nbytes_temp; + + if ((status = H5Pget_chunk_cache((hid_t)dapl, &rdcc_nslots_t, &nbytes_t, (double *)w0Array)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + *rdcc_nslotsArray = (jlong)rdcc_nslots_t; + *nbytesArray = (jlong)nbytes_t; + } /* end direct cast special handling */ + +done: + if (nbytesArray) + UNPIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, (status < 0) ? JNI_ABORT : 0); + if (rdcc_nslotsArray) + UNPIN_LONG_ARRAY(ENVONLY, rdcc_nslots, rdcc_nslotsArray, (status < 0) ? JNI_ABORT : 0); + if (w0Array) + UNPIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, (status < 0) ? JNI_ABORT : 0); +} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_efile_prefix + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix + (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) +{ + const char *extFilePrefix = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, prefix, extFilePrefix, NULL, "H5Pset_efile_prefix: external file prefix not pinned"); + + if ((retVal = H5Pset_efile_prefix((hid_t)dapl_id, extFilePrefix)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (extFilePrefix) + UNPIN_JAVA_STRING(ENVONLY, prefix, extFilePrefix); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_efile_prefix + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix + (JNIEnv *env, jclass clss, jlong dapl_id) +{ + ssize_t prefix_size = -1; + char *pre = NULL; + jstring str = NULL; + + UNUSED(clss); + + if ((prefix_size = H5Pget_efile_prefix((hid_t)dapl_id, (char *)NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t)prefix_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: memory allocation failed"); + + if (H5Pget_efile_prefix((hid_t)dapl_id, (char *)pre, (size_t)prefix_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + pre[(size_t)prefix_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_efile_prefix: out of memory - unable to construct string from UTF characters"); + } + +done: + if (pre) + HDfree(pre); + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_append_flush + * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1append_1flush + (JNIEnv *env, jclass clss, jlong plist_id, jint ndims, jlongArray boundary, jobject callback_op, jobject op_data) +{ + cb_wrapper wrapper = { callback_op, op_data }; + herr_t status = FAIL; + + UNUSED(clss); + + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_append_flush: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_append_flush: callback_op is NULL"); + + if ((status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t *)boundary, (H5D_append_cb_t)H5D_append_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1append_1flush */ + +/* + * TODO: H5Pget_append_flush + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_view + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view + (JNIEnv *env, jclass clss, jlong dapl_id, jint view) +{ + UNUSED(clss); + + if (H5Pset_virtual_view((hid_t)dapl_id, (H5D_vds_view_t)view) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_view + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view + (JNIEnv *env, jclass clss, jlong dapl_id) +{ + H5D_vds_view_t virtual_view = H5D_VDS_ERROR; + + UNUSED(clss); + + if (H5Pget_virtual_view((hid_t)dapl_id, &virtual_view) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)virtual_view; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_printf_gap + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap + (JNIEnv *env, jclass clss, jlong dapl_id, jlong gap_size) +{ + UNUSED(clss); + + if (H5Pset_virtual_printf_gap((hid_t)dapl_id, (hsize_t)gap_size) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_printf_gap + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap + (JNIEnv *env, jclass clss, jlong dapl_id) +{ + hsize_t gap_size = 0; + + UNUSED(clss); + + if (H5Pget_virtual_printf_gap((hid_t)dapl_id, &gap_size) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)gap_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap */ + +static herr_t +H5D_append_cb + (hid_t dataset_id, hsize_t *cur_dims, void *cb_data) +{ + cb_wrapper *wrapper = (cb_wrapper *)cb_data; + jlongArray cur_dimsArray; + jmethodID mid; + jobject visit_callback = wrapper->visit_callback; + jclass cls; + JNIEnv *cbenv = NULL; + void *op_data = (void *)wrapper->op_data; + jint status = -1; + + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5D_append_cb: failed to attach current thread to JVM"); + } + + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(J[JLhdf/hdf5lib/callbacks/H5D_append_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + if (NULL != cur_dims) { + if (NULL == (cur_dimsArray = CBENVPTR->NewLongArray(CBENVONLY, 2))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + CBENVPTR->SetLongArrayRegion(CBENVONLY, cur_dimsArray, 0, 2, (const jlong *)cur_dims); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, dataset_id, cur_dims, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + } + +done: + if (CBENVONLY) + JVMPTR->DetachCurrentThread(JVMPAR); + + return (herr_t)status; +} /* end H5D_append_cb */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pDAPLImp.h b/java/src/jni/h5pDAPLImp.h new file mode 100644 index 0000000..a9fbadd --- /dev/null +++ b/java/src/jni/h5pDAPLImp.h @@ -0,0 +1,112 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PDAPL +#define _Included_hdf_hdf5lib_H5_H5PDAPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_cache + * Signature: (JJJD)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache +(JNIEnv *, jclass, jlong, jlong, jlong, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_cache + * Signature: (J[J[J[D)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache +(JNIEnv *, jclass, jlong, jlongArray, jlongArray, jdoubleArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_efile_prefix + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_efile_prefix + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_append_flush + * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1append_1flush + (JNIEnv*, jclass, jlong, jint, jlongArray, jobject, jobject); + +/* + * TODO: H5Pget_append_flush + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_view + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_view + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_printf_gap + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_printf_gap + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap +(JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PDAPL */ diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c new file mode 100644 index 0000000..0671843 --- /dev/null +++ b/java/src/jni/h5pDCPLImp.c @@ -0,0 +1,1404 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pDCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_layout + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1layout + (JNIEnv *env, jclass clss, jlong plist, jint layout) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_layout((hid_t)plist, (H5D_layout_t)layout)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1layout */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_layout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1layout + (JNIEnv *env, jclass clss, jlong plist) +{ + H5D_layout_t retVal = H5D_LAYOUT_ERROR; + + UNUSED(clss); + + if (H5D_LAYOUT_ERROR == (retVal = H5Pget_layout((hid_t)plist))) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1layout */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk + (JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) +{ + jboolean isCopy; + hsize_t *da = NULL; + hsize_t *lp = NULL; + size_t i; + size_t rank; + jsize arrLen; + jbyte *theArray = NULL; + jlong *jlp = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (ndims < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: ndims < 0"); + if (NULL == dim) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: dim array is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, dim)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: dim array length < 0"); + } + + rank = (size_t) arrLen / sizeof(jlong); + if (rank < (size_t) ndims) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_chunk: dims array rank < ndims"); + + PIN_BYTE_ARRAY(ENVONLY, dim, theArray, &isCopy, "H5Pset_chunk: dim array not pinned"); + + if (NULL == (da = lp = (hsize_t *) HDmalloc(rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_chunk: memory allocation failed"); + + jlp = (jlong *)theArray; + for (i = 0; i < rank; i++) { + *lp = (hsize_t)*jlp; + lp++; + jlp++; + } /* end if */ + + if ((status = H5Pset_chunk((hid_t)plist, (int)ndims, da)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (da) + HDfree(da); + if (theArray) + UNPIN_BYTE_ARRAY(ENVONLY, dim, theArray, JNI_ABORT); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk + * Signature: (JI[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk + (JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims) +{ + jboolean isCopy; + hsize_t *da = NULL; + jlong *theArray = NULL; + jsize arrLen; + int i; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_chunk: dims is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_chunk: dims array length < 0"); + } + if (arrLen < max_ndims) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_chunk: dims array < max_ndims"); + + PIN_LONG_ARRAY(ENVONLY, dims, theArray, &isCopy, "H5Pget_chunk: input dims not pinned"); + + if (NULL == (da = (hsize_t *) HDmalloc((size_t)max_ndims * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_chunk: memory allocation failed"); + + if ((status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < max_ndims; i++) + theArray[i] = (jlong)da[i]; + +done: + if (da) + HDfree(da); + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, dims, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_opts + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts + (JNIEnv *env, jclass clss, jlong dcpl_id, jint opts) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_chunk_opts((hid_t)dcpl_id, (unsigned)opts)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_opts + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts + (JNIEnv *env, jclass clss, jlong dcpl_id) +{ + unsigned opts = 0; + + UNUSED(clss); + + if (H5Pget_chunk_opts((hid_t)dcpl_id, &opts) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)opts; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong dcpl_id, jboolean minimize) +{ + hbool_t minimize_val; + herr_t retVal = FAIL; + + UNUSED(clss); + + minimize_val = (JNI_TRUE == minimize) ? TRUE : FALSE; + + if ((retVal = H5Pset_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t)minimize_val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint +(JNIEnv *env, jclass clss, jlong dcpl_id) +{ + hbool_t minimize = FALSE; + jboolean bval = JNI_FALSE; + + UNUSED(clss); + + if (H5Pget_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t *)&minimize) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (minimize == TRUE) + bval = JNI_TRUE; + +done: + return bval; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_deflate + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1deflate + (JNIEnv *env, jclass clss, jlong plist, jint level) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_deflate((hid_t)plist, (unsigned)level)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1deflate */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1value + (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +{ + jboolean isCopy; + jbyte *byteP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) { + if ((status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + else { + PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Pget_fill_value: value array not pinned"); + + if ((status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + +done: + if (byteP) + UNPIN_BYTE_ARRAY(ENVONLY, value, byteP, JNI_ABORT); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1value + (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +{ + jboolean isCopy; + herr_t status = FAIL; + jbyte *byteP = NULL; + + UNUSED(clss); + + if (NULL == value) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_fill_value: value is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Pget_fill_value: value array not pinned"); + + if ((status = H5Pget_fill_value((hid_t)plist_id, (hid_t)type_id, byteP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (byteP) + UNPIN_BYTE_ARRAY(ENVONLY, value, byteP, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pfill_value_defined + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined + (JNIEnv *env, jclass clss, jlong plist, jintArray status) +{ + H5D_fill_value_t value = H5D_FILL_VALUE_ERROR; + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == status) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pfill_value_defined: status is NULL"); + + PIN_INT_ARRAY(ENVONLY, status, theArray, &isCopy, "H5Pfill_value_defined: status not pinned"); + + if ((retVal = H5Pfill_value_defined((hid_t)plist, &value)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jint)value; + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, status, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1time + (JNIEnv *env, jclass clss, jlong plist, jint fill_time) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fill_time((hid_t)plist, (H5D_fill_time_t)fill_time)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1time + (JNIEnv *env, jclass clss, jlong plist, jintArray fill_time) +{ + H5D_fill_time_t time = H5D_FILL_TIME_ERROR; + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == fill_time) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_fill_time: fill_time is NULL"); + + PIN_INT_ARRAY(ENVONLY, fill_time, theArray, &isCopy, "H5Pget_fill_time: fill_time not pinned"); + + if ((retVal = H5Pget_fill_time((hid_t)plist, &time)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jint)time; + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, fill_time, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alloc_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time + (JNIEnv *env, jclass clss, jlong plist, jint alloc_time) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_alloc_time((hid_t)plist, (H5D_alloc_time_t)alloc_time)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alloc_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time + (JNIEnv *env, jclass clss, jlong plist, jintArray alloc_time) +{ + H5D_alloc_time_t time = H5D_ALLOC_TIME_ERROR; + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == alloc_time) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_alloc_time: alloc_time is NULL"); + + PIN_INT_ARRAY(ENVONLY, alloc_time, theArray, &isCopy, "H5Pget_alloc_time: alloc_time not pinned"); + + if ((retVal = H5Pget_alloc_time((hid_t)plist, &time)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = time; + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, alloc_time, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1filter + (JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, + jlong cd_nelmts, jintArray cd_values) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == cd_values) { + if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int)flags, (size_t)cd_nelmts, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + else { + PIN_INT_ARRAY(ENVONLY, cd_values, theArray, &isCopy, "H5Pset_filter: input array not pinned"); + + if ((status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int)flags, (size_t)cd_nelmts, (const unsigned int *)theArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, cd_values, theArray, JNI_ABORT); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pall_filters_avail + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail + (JNIEnv *env, jclass clss, jlong dcpl_id) +{ + htri_t bval = JNI_FALSE; + + UNUSED(clss); + + if ((bval = H5Pall_filters_avail((hid_t)dcpl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nfilters + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nfilters + (JNIEnv *env, jclass clss, jlong plist) +{ + int retVal = -1; + + UNUSED(clss); + + if ((retVal = H5Pget_nfilters((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nfilters */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter + (JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags, + jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +{ + jboolean isCopy; + jstring str; + jint *flagsArray = NULL; + jlong *cd_nelmtsArray = NULL; + jint *cd_valuesArray = NULL; + char *filter = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (namelen <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: namelen <= 0"); + if (NULL == flags) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: flags is NULL"); + if (NULL == cd_nelmts) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: cd_nelmts is NULL"); + if (NULL == cd_values) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter: cd_values is NULL"); + + if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: memory allocation failed"); + + PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter: flags array not pinned"); + PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter: nelmts array not pinned"); + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter: elmts array not pinned"); + + + /* direct cast (size_t *)variable fails on 32-bit environment */ + { + unsigned int filter_config; + long long cd_nelmts_temp = *cd_nelmtsArray; + size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, filter, &filter_config)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + filter[namelen - 1] = '\0'; + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (cd_valuesArray) + UNPIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, (status < 0) ? JNI_ABORT : 0); + if (cd_nelmtsArray) + UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); + if (flagsArray) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0) + if (filter) + HDfree(filter); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter2 + (JNIEnv *env, jclass clss, jlong plist, jint filter_number, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, + jobjectArray name, jintArray filter_config) +{ + jboolean isCopy; + jstring str; + jint *flagsArray = NULL; + jlong *cd_nelmtsArray = NULL; + jint *cd_valuesArray = NULL; + jint *filter_configArray = NULL; + char *filter = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (namelen <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: namelen <= 0"); + if (NULL == flags) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: flags is NULL"); + if (NULL == cd_nelmts) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: cd_nelmts is NULL"); + if (NULL == filter_config) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: filter_config is NULL"); + + if (NULL == (filter = (char *) HDmalloc(sizeof(char) * (size_t)namelen))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: memory allocation failed"); + + PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter2: flags array not pinned"); + PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter2: nelmts array not pinned"); + PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, "H5Pget_filter2: filter_config array not pinned"); + + if (NULL == cd_values && *cd_nelmtsArray == 0) { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = 0; + size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, NULL, + (size_t)namelen, filter, (unsigned int *)filter_configArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + filter[namelen - 1] = '\0'; + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } + else { + if (NULL == cd_values) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter2: cd_values is NULL"); + + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter2: elmts array not pinned"); + + { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *cd_nelmtsArray; + size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + + if ((status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, filter, (unsigned int *)filter_configArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + filter[namelen - 1] = '\0'; + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special */ + } + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, filter))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter2: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (cd_valuesArray) + UNPIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, (status < 0) ? JNI_ABORT : 0); + if (filter_configArray) + UNPIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, (status < 0) ? JNI_ABORT : 0); + if (cd_nelmtsArray) + UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); + if (flagsArray) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0); + if (filter) + HDfree(filter); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id + (JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) +{ + jboolean isCopy; + jstring str; + jlong *cd_nelmtsArray = NULL; + jint *cd_valuesArray = NULL; + jint *flagsArray = NULL; + char *aName = NULL; + long bs; + int rank; + herr_t status = FAIL; + + UNUSED(clss); + + bs = (long)namelen; + + if (bs <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: namelen <= 0"); + if (NULL == flags) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: flags is NULL"); + if (NULL == cd_nelmts) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: cd_nelmts is NULL"); + if (NULL == cd_values) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: cd_values is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: name is NULL"); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: memory allocation failed"); + + PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id: flags not pinned"); + PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id: cd_nelms not pinned"); + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter_by_id: cd_values array not pinned"); + + if ((rank = ENVPTR->GetArrayLength(ENVONLY, cd_values)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id: cd_values array length < 0"); + } + + { + /* direct cast (size_t *)variable fails on 32-bit environment */ + unsigned int filter_config; + long long cd_nelmts_temp = *cd_nelmtsArray; + size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + + if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, (char *)aName, &filter_config)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + aName[bs - 1] = '\0'; + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special */ + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (cd_valuesArray) + UNPIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, (status < 0) ? JNI_ABORT : 0); + if (cd_nelmtsArray) + UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); + if (flagsArray) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0); + if (aName) + HDfree(aName); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 + (JNIEnv *env, jclass clss, jlong plist, jint filter, + jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name, jintArray filter_config) +{ + jboolean isCopy; + jstring str; + jlong *cd_nelmtsArray = NULL; + jint *cd_valuesArray = NULL; + jint *flagsArray = NULL; + jint *filter_configArray = NULL; + long bs; + char *aName = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + bs = (long)namelen; + + if (bs <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: namelen <= 0"); + if (NULL == flags) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: flags is NULL"); + if (NULL == cd_nelmts) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: cd_nelmts is NULL"); + if (NULL == cd_values) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: cd_values is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: name is NULL"); + if (NULL == filter_config) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_filter_by_id2: filter_config is NULL"); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)bs))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: memory allocation failed"); + + PIN_INT_ARRAY(ENVONLY, flags, flagsArray, &isCopy, "H5Pget_filter_by_id2: flags not pinned"); + PIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, &isCopy, "H5Pget_filter_by_id2: cd_nelms not pinned"); + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, &isCopy, "H5Pget_filter_by_id2: cd_values array not pinned"); + PIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, &isCopy, "H5Pget_filter_by_id2: filter_config not pinned"); + + { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long cd_nelmts_temp = *cd_nelmtsArray; + size_t cd_nelmts_t = (size_t) cd_nelmts_temp; + + if ((status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, + (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, + (size_t)namelen, (char *)aName, (unsigned int *)filter_configArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + aName[bs - 1] = '\0'; + + *cd_nelmtsArray = (jlong)cd_nelmts_t; + } /* end direct cast special handling */ + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_filter_by_id2: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (filter_configArray) + UNPIN_INT_ARRAY(ENVONLY, filter_config, filter_configArray, (status < 0) ? JNI_ABORT : 0); + if (cd_valuesArray) + UNPIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesArray, (status < 0) ? JNI_ABORT : 0); + if (cd_nelmtsArray) + UNPIN_LONG_ARRAY(ENVONLY, cd_nelmts, cd_nelmtsArray, (status < 0) ? JNI_ABORT : 0); + if (flagsArray) + UNPIN_INT_ARRAY(ENVONLY, flags, flagsArray, (status < 0) ? JNI_ABORT : 0); + if (aName) + HDfree(aName); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pmodify_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pmodify_1filter + (JNIEnv *env, jclass clss, jlong plist, jint filter, + jint flags, jlong cd_nelmts, jintArray cd_values) +{ + jboolean isCopy; + jint *cd_valuesP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == cd_values) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pmodify_filter: cd_values is NULL"); + + PIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesP, &isCopy, "H5Pmodify_filter: cd_values not pinned"); + + if ((status = H5Pmodify_filter((hid_t)plist, (H5Z_filter_t)filter, (const unsigned int)flags, + (size_t)cd_nelmts, (unsigned int *)cd_valuesP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (cd_valuesP) + UNPIN_INT_ARRAY(ENVONLY, cd_values, cd_valuesP, JNI_ABORT); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pmodify_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove_filter + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5P1remove_1filter + (JNIEnv *env, jclass clss, jlong obj_id, jint filter) +{ + herr_t status = FAIL; + + UNUSED(clss); + + if ((status = H5Premove_filter((hid_t)obj_id, (H5Z_filter_t)filter)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5P1remove_1filter */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fletcher32 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 + (JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fletcher32((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nbit + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nbit + (JNIEnv *env, jclass clss, jlong plist_id) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_nbit((hid_t)plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1nbit */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_scaleoffset + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset + (JNIEnv *env, jclass clss, jlong plist_id, jint scale_type, jint scale_factor) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if (scale_factor <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_scaleoffset: scale factor must be > 0"); + if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_scaleoffset: invalid scale type"); + + if ((retVal = H5Pset_scaleoffset((hid_t)plist_id, (H5Z_SO_scale_type_t)scale_type, scale_factor)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shuffle + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shuffle + (JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_shuffle((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shuffle */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_szip + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1szip + (JNIEnv *env, jclass clss, jlong plist, jint options_mask, jint pixels_per_block) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_szip((hid_t)plist, (unsigned int)options_mask, (unsigned int)pixels_per_block)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1szip */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_external + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1external + (JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, jlong size) +{ + const char *fileName = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Pset_external: file name not pinned"); + + if ((status = H5Pset_external((hid_t)plist, fileName, (off_t)offset, (hsize_t)size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, name, fileName); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1external */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external + * Signature: (JIJ[Ljava/lang/String;[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external + (JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size, + jobjectArray name, jlongArray size) +{ + jboolean isCopy; + jstring str; + hsize_t s; + off_t o; + jsize arrLen; + jlong *theArray = NULL; + char *file = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (name_size < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_external: name_size < 0"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, size)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_external: size array length < 0"); + } + if ((size != NULL) && (arrLen < 2)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_external: size input array < 2"); + + if (name_size > 0) + if (NULL == (file = (char *) HDmalloc(sizeof(char) * (size_t)name_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: memory allocation failed"); + + if ((status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, + file, (off_t *)&o, (hsize_t *)&s)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL != size) { + PIN_LONG_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_external: size array not pinned"); + + theArray[0] = o; + theArray[1] = (jlong)s; + } + + if (NULL != file) { + file[name_size - 1] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, file))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_external: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, size, theArray, (status < 0) ? JNI_ABORT : 0); + if (file) + HDfree(file); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1external */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external_count + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external_1count + (JNIEnv *env, jclass clss, jlong plist) +{ + int retVal = -1; + + UNUSED(clss); + + if ((retVal = H5Pget_external_count((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1external_1count */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual + * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong vspace_id, + jstring src_file_name, jstring src_dset_name, jlong src_space_id) +{ + const char *fstr = NULL; + const char *dstr = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, src_file_name, fstr, NULL, "H5Pset_virtual: src_file_name not pinned"); + PIN_JAVA_STRING(ENVONLY, src_dset_name, dstr, NULL, "H5Pset_virtual: src_dset_name not pinned"); + + if ((retVal = H5Pset_virtual((hid_t)dcpl_id, (hid_t)vspace_id, fstr, dstr, (hid_t)src_space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (dstr) + UNPIN_JAVA_STRING(ENVONLY, src_dset_name, dstr); + if (fstr) + UNPIN_JAVA_STRING(ENVONLY, src_file_name, fstr); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_count + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count + (JNIEnv *env, jclass clss, jlong dcpl_id) +{ + size_t s = 0; + + UNUSED(clss); + + if (H5Pget_virtual_count((hid_t)dcpl_id, &s) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_dsetname + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + ssize_t buf_size; + char *dname = NULL; + jstring str = NULL; + + UNUSED(clss); + + /* get the length of the filename */ + if ((buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (dname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: memory allocation failed"); + + if (H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, dname, (size_t)buf_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + dname[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, dname))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_dsetname: out of memory - unable to construct string from UTF characters"); + } + +done: + if (dname) + HDfree(dname); + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_filename + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + ssize_t buf_size; + char *fname = NULL; + jstring str = NULL; + + UNUSED(clss); + + /* get the length of the filename */ + if ((buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (fname = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: memory allocation failed"); + + if (H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, fname, (size_t)buf_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + fname[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, fname))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_filename: out of memory - unable to construct string from UTF characters"); + } + +done: + if (fname) + HDfree(fname); + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_srcspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + hid_t space_id = H5I_INVALID_HID; + + UNUSED(clss); + + if ((space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t)index)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)space_id; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_vspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace + (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) +{ + hid_t space_id = H5I_INVALID_HID; + + UNUSED(clss); + + if ((space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t)index)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)space_id; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_prefix + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix + (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) +{ + const char *virtPrefix = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, prefix, virtPrefix, NULL, "H5Pset_virtual_prefix: virtual prefix not pinned"); + + if ((retVal = H5Pset_virtual_prefix((hid_t)dapl_id, virtPrefix)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (virtPrefix) + UNPIN_JAVA_STRING(ENVONLY, prefix, virtPrefix); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_prefix + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix + (JNIEnv *env, jclass clss, jlong dapl_id) +{ + ssize_t prefix_size = -1; + char *pre = NULL; + jstring str = NULL; + + UNUSED(clss); + + if ((prefix_size = H5Pget_virtual_prefix((hid_t)dapl_id, (char *)NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: memory allocation failed"); + + if (H5Pget_virtual_prefix((hid_t)dapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + pre[prefix_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_virtual_prefix: out of memory - unable to construct string from UTF characters"); + } + +done: + if (pre) + HDfree(pre); + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pDCPLImp.h b/java/src/jni/h5pDCPLImp.h new file mode 100644 index 0000000..6e5c225 --- /dev/null +++ b/java/src/jni/h5pDCPLImp.h @@ -0,0 +1,396 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PDCPL +#define _Included_hdf_hdf5lib_H5_H5PDCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_layout + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1layout +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_layout + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1layout +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk + * Signature: (JI[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk +(JNIEnv *, jclass, jlong, jint, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk + * Signature: (JI[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk +(JNIEnv *, jclass, jlong, jint, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_chunk_opts + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_chunk_opts + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_dset_no_attrs_hint + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_dset_no_attrs_hint + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_deflate + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1deflate +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1value +(JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_value + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1value +(JNIEnv *, jclass, jlong, jlong, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pfill_value_defined + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fill_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fill_1time +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fill_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fill_1time +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alloc_time + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alloc_time + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1filter +(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pall_filters_avail + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nfilters + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nfilters +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter2 +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id + * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_filter_by_id2 + * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 +(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pmodify_filter + * Signature: (JIIJ[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pmodify_1filter +(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Premove_filter + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5P1remove_1filter +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fletcher32 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nbit + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nbit +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_scaleoffset + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shuffle + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shuffle +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_szip + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1szip +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_external + * Signature: (JLjava/lang/String;JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1external +(JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external + * Signature: (JIJ[Ljava/lang/String;[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external +(JNIEnv *, jclass, jlong, jint, jlong, jobjectArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_external_count + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1external_1count +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual + * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual +(JNIEnv *, jclass, jlong, jlong, jstring, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_count + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_dsetname + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_filename + * Signature: (JJ)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_srcspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_vspace + * Signature: (JJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_virtual_prefix + * Signature: (JLjava/lang/String;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_virtual_prefix + * Signature: (J)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix +(JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PDCPL */ diff --git a/java/src/jni/h5pDXPLImp.c b/java/src/jni/h5pDXPLImp.c new file mode 100644 index 0000000..2bdc36b --- /dev/null +++ b/java/src/jni/h5pDXPLImp.c @@ -0,0 +1,502 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pDXPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer + * Signature: (JJ[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer + (JNIEnv *env, jclass clss, jlong plist, jlong size, jbyteArray tconv, jbyteArray bkg) +{ +#ifdef notdef + jboolean isCopy; + jbyte *tconvP = NULL; + jbyte *bkgP = NULL; +#endif + herr_t status = FAIL; + + UNUSED(clss); +#ifndef notdef + UNUSED(plist); + UNUSED(size); + UNUSED(tconv); + UNUSED(bkg); +#endif + + H5_UNIMPLEMENTED(ENVONLY, "H5Pset_buffer: not implemented"); + + /* NOTE: DON'T IMPLEMENT THIS!!! */ +#ifdef notdef + if (NULL != tconv) + PIN_BYTE_ARRAY(ENVONLY, tconv, tconvP, &isCopy, "H5Pset_buffer: tconv not pinned"); + if (NULL != bkg) + PIN_BYTE_ARRAY(ENVONLY, bkg, bkgP, &isCopy, "H5Pset_buffer: bkg not pinned"); + + if ((status = H5Pset_buffer((hid_t)plist, (size_t)size, tconvP, bkgP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +#endif + +done: +#ifdef notdef + if (bkgP) + UNPIN_BYTE_ARRAY(ENVONLY, bkg, bkgP, (status < 0) ? JNI_ABORT : 0); + if (tconvP) + UNPIN_BYTE_ARRAY(ENVONLY, tconv, tconvP, (status < 0) ? JNI_ABORT : 0); +#endif + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer + * Signature: (J[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer + (JNIEnv *env, jclass clss, jlong plist, jbyteArray tconv, jbyteArray bkg) +{ +#ifdef notdef + jboolean isCopy; + jbyte *tconvP = NULL; + jbyte *bkgP = NULL; +#endif + herr_t status = FAIL; + + UNUSED(clss); +#ifndef notdef + UNUSED(plist); + UNUSED(tconv); + UNUSED(bkg); +#endif + + H5_UNIMPLEMENTED(ENVONLY, "H5Pget_buffer: not implemented"); + + /* NOTE: DON'T IMPLEMENT THIS!!! */ +#ifdef notdef + if (NULL == tconv) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_buffer: tconv input array is NULL"); + if (NULL == bkg) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_buffer: bkg array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, tconv, tconvP, &isCopy, "H5Pget_buffer: tconv not pinned"); + PIN_BYTE_ARRAY(ENVONLY, bkg, bkgP, &isCopy, "H5Pget_buffer: bkg not pinned"); + + if ((status = H5Pget_buffer((hid_t)plist, tconvP, bkgP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +#endif + +done: +#ifdef notdef + if (bkgP) + UNPIN_BYTE_ARRAY(ENVONLY, bkg, bkgP, (status < 0) ? JNI_ABORT : 0); + if (tconvP) + UNPIN_BYTE_ARRAY(ENVONLY, tconv, tconvP, (status < 0) ? JNI_ABORT : 0); +#endif + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size + (JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + UNUSED(clss); + + if (H5Pset_buffer((hid_t)plist, (size_t)size, NULL, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size + (JNIEnv *env, jclass clss, jlong plist) +{ + size_t size = 0; + + UNUSED(clss); + + if (!(size = H5Pget_buffer((hid_t)plist, NULL, NULL))) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_preserve + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1preserve + (JNIEnv *env, jclass clss, jlong plist, jboolean status) +{ + hbool_t st = JNI_FALSE; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (JNI_TRUE == status) + st = TRUE; + else if (JNI_FALSE == status) + st = false; + else + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_preserve: status not TRUE or FALSE"); + + if ((retVal = H5Pset_preserve((hid_t)plist, st)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1preserve */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_preserve + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1preserve + (JNIEnv *env, jclass clss, jlong plist) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pget_preserve((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1preserve */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_edc_check + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1edc_1check + (JNIEnv *env, jclass clss, jlong plist, jint check) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_edc_check((hid_t)plist, (H5Z_EDC_t)check)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1edc_1check */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_edc_check + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1edc_1check + (JNIEnv *env, jclass clss, jlong plist) +{ + H5Z_EDC_t retVal = -1; + + UNUSED(clss); + + if ((retVal = H5Pget_edc_check((hid_t)plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1edc_1check */ + +/* + * TODO: H5Pset_filter_callback + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_data_transform + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1data_1transform + (JNIEnv *env, jclass clss, jlong plist_id, jstring expression) +{ + const char *express = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, expression, express, NULL, "H5Pset_data_transform: data transform expression not pinned"); + + if ((retVal = H5Pset_data_transform((hid_t)plist_id, express)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (express) + UNPIN_JAVA_STRING(ENVONLY, expression, express); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1data_1transform */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_data_transform + * Signature: (J[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1data_1transform + (JNIEnv *env, jclass clss, jlong plist_id, jobjectArray expression, jlong size) +{ + jstring str = NULL; + char *express = NULL; + ssize_t express_size = -1; + + UNUSED(clss); + + if (size <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_data_transform: size <= 0"); + + if ((express_size = H5Pget_data_transform((hid_t)plist_id, (char *)NULL, (size_t)size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (express = (char *) HDmalloc(sizeof(char) * (size_t)express_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: memory allocation failed"); + + if (H5Pget_data_transform((hid_t)plist_id, express, (size_t)express_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + express[express_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, express))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_data_transform: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, expression, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (express) + HDfree(express); + + return (jlong)express_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1data_1transform */ + +/* + * TODO: H5Pset_type_conv_cb + */ + +/* + * TODO: H5Pget_type_conv_cb + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_hyper_vector_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size + (JNIEnv *env, jclass clss, jlong plist, jlong vector_size) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_hyper_vector_size((hid_t)plist, (size_t)vector_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_hyper_vector_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size + (JNIEnv *env, jclass clss, jlong plist, jlongArray vector_size) +{ + jboolean isCopy; + size_t size; + jlong *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == vector_size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_hyper_vector_size: vector_size is NULL"); + + PIN_LONG_ARRAY(ENVONLY, vector_size, theArray, &isCopy, "H5Pget_hyper_vector_size: vector_size not pinned"); + + if ((retVal = H5Pget_hyper_vector_size((hid_t)plist, &size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jlong)size; + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, vector_size, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_btree_ratios + * Signature: (JDDD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios + (JNIEnv *env, jclass clss, jlong plist_id, jdouble left, jdouble middle, jdouble right) +{ + herr_t status = FAIL; + + UNUSED(clss); + + if ((status = H5Pset_btree_ratios((hid_t)plist_id, (double)left,(double)middle, (double)right)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_btree_ratios + * Signature: (J[D[D[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios + (JNIEnv *env, jclass clss, jlong plist_id, jdoubleArray left, + jdoubleArray middle, jdoubleArray right) +{ + jboolean isCopy; + jdouble *leftP = NULL; + jdouble *middleP = NULL; + jdouble *rightP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == left) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_btree_ratios: left input array is NULL"); + if (NULL == middle) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_btree_ratios: middle input array is NULL"); + if (NULL == right) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_btree_ratios: right input array is NULL"); + + PIN_DOUBLE_ARRAY(ENVONLY, left, leftP, &isCopy, "H5Pget_btree_ratios: left array not pinned"); + PIN_DOUBLE_ARRAY(ENVONLY, middle, middleP, &isCopy, "H5Pget_btree_ratios: middle array not pinned"); + PIN_DOUBLE_ARRAY(ENVONLY, right, rightP, &isCopy, "H5Pget_btree_ratios: right array not pinned"); + + if ((status = H5Pget_btree_ratios((hid_t)plist_id, (double *)leftP, + (double *)middleP, (double *)rightP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (rightP) + UNPIN_DOUBLE_ARRAY(ENVONLY, right, rightP, (status < 0) ? JNI_ABORT : 0); + if (middleP) + UNPIN_DOUBLE_ARRAY(ENVONLY, middle, middleP, (status < 0) ? JNI_ABORT : 0); + if (leftP) + UNPIN_DOUBLE_ARRAY(ENVONLY, left, leftP, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios */ + +/* + * TODO: H5Pset_vlen_mem_manager + */ + +/* + * TODO: H5Pget_vlen_mem_manager + */ + +/* + * TODO: H5Pset_dxpl_mpio + */ + +/* + * TODO: H5Pget_dxpl_mpio + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt_num + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt_ratio + */ + +/* + * TODO: H5Pset_dxpl_mpio_collective_opt + */ + +/* + * TODO: H5Pget_mpio_actual_chunk_opt_mode + */ + +/* + * TODO: H5Pget_mpio_actual_io_mode + */ + +/* + * TODO: H5Pget_mpio_no_collective_cause + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pDXPLImp.h b/java/src/jni/h5pDXPLImp.h new file mode 100644 index 0000000..d62f9c5 --- /dev/null +++ b/java/src/jni/h5pDXPLImp.h @@ -0,0 +1,209 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PDXPL +#define _Included_hdf_hdf5lib_H5_H5PDXPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer + * Signature: (JJ[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer +(JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer + * Signature: (J[B[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer +(JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_buffer_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_buffer_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_preserve + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1preserve +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_preserve + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1preserve +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_edc_check + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1edc_1check +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_edc_check + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1edc_1check +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pset_filter_callback + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_data_transform + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1data_1transform +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_data_transform + * Signature: (J[Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1data_1transform +(JNIEnv *, jclass, jlong, jobjectArray, jlong); + +/* + * TODO: H5Pset_type_conv_cb + */ + +/* + * TODO: H5Pget_type_conv_cb + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_hyper_vector_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_hyper_vector_size + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_btree_ratios + * Signature: (JDDD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios +(JNIEnv *, jclass, jlong, jdouble, jdouble, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_btree_ratios + * Signature: (J[D[D[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios +(JNIEnv *, jclass, jlong, jdoubleArray, jdoubleArray, jdoubleArray); + +/* + * TODO: H5Pset_vlen_mem_manager + */ + +/* + * TODO: H5Pget_vlen_mem_manager + */ + +/* + * TODO: H5Pset_dxpl_mpio + */ + +/* + * TODO: H5Pget_dxpl_mpio + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt_num + */ + +/* + * TODO: H5Pset_dxpl_mpio_chunk_opt_ratio + */ + +/* + * TODO: H5Pset_dxpl_mpio_collective_opt + */ + +/* + * TODO: H5Pget_mpio_actual_chunk_opt_mode + */ + +/* + * TODO: H5Pget_mpio_actual_io_mode + */ + +/* + * TODO: H5Pget_mpio_no_collective_cause + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PDXPL */ diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c new file mode 100644 index 0000000..aec6581 --- /dev/null +++ b/java/src/jni/h5pFAPLImp.c @@ -0,0 +1,1624 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5util.h" +#include "h5pFAPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * TODO: H5Pset_driver + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_driver + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1driver + (JNIEnv *env, jclass clss, jlong plist) +{ + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if ((retVal = H5Pget_driver((hid_t) plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1driver */ + +/* + * TODO: H5Pget_driver_info + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fclose_degree + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree + (JNIEnv *env, jclass clss, jlong plist, jint fc_degree) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fclose_degree((hid_t)plist, (H5F_close_degree_t)fc_degree)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fclose_degree + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree + (JNIEnv *env, jclass clss, jlong plist) +{ + H5F_close_degree_t degree = H5F_CLOSE_DEFAULT; + + UNUSED(clss); + + if (H5Pget_fclose_degree((hid_t)plist, °ree) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)degree; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_core + * Signature: (JJZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core + (JNIEnv *env, jclass clss, jlong fapl_id, jlong increment, jboolean backing_store) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fapl_core((hid_t)fapl_id, (size_t)increment, (hbool_t)backing_store)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_core + * Signature: (J[J[Z)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core + (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray increment, jbooleanArray backing_store) +{ + jboolean isCopy; + jboolean *backArray = NULL; + jlong *incArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == increment) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_fapl_core: increment is NULL"); + if (NULL == backing_store) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_fapl_core: backing_store is NULL"); + + PIN_LONG_ARRAY(ENVONLY, increment, incArray, &isCopy, "H5Pget_fapl_core: incArray not pinned"); + PIN_BOOL_ARRAY(ENVONLY, backing_store, backArray, &isCopy, "H5Pget_fapl_core: backArray not pinned"); + + { + /* Direct cast (size_t *)variable fails on 32-bit environment */ + long long inc_temp = *incArray; + size_t inc_t = (size_t) inc_temp; + + if ((status = H5Pget_fapl_core((hid_t)fapl_id, &inc_t, (hbool_t *)backArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + *incArray = (jlong)inc_t; + } + +done: + if (backArray) + UNPIN_BOOL_ARRAY(ENVONLY, backing_store, backArray, (status < 0) ? JNI_ABORT : 0); + if (incArray) + UNPIN_LONG_ARRAY(ENVONLY, increment, incArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core */ + +/* + * TODO: H5Pset_core_write_tracking + */ + +/* + * TODO: H5Pget_core_write_tracking + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_direct + * Signature: (JJJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct + (JNIEnv *env, jclass clss, jlong fapl_id, jlong alignment, + jlong block_size, jlong cbuf_size) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + +#ifdef H5_HAVE_DIRECT + if ((retVal = H5Pset_fapl_direct((hid_t)fapl_id, (size_t)alignment, (size_t)block_size, (size_t)cbuf_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: +#else + UNUSED(env); + UNUSED(fapl_id); + UNUSED(alignment); + UNUSED(block_size); + UNUSED(cbuf_size); +#endif + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_direct + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct + (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray info) +{ +#ifdef H5_HAVE_DIRECT + jboolean isCopy; + jlong *theArray = NULL; + size_t alignment = 0; + size_t block_size = 0; + size_t cbuf_size = 0; + jsize arrLen; +#endif + herr_t retVal = FAIL; + + UNUSED(clss); + +#ifdef H5_HAVE_DIRECT + if (NULL == info) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_fapl_direct: info input array is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, info)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_fapl_direct: info array length < 0"); + } + if (arrLen < 3) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_fapl_direct: info input array < 3"); + + PIN_LONG_ARRAY(ENVONLY, info, theArray, &isCopy, "H5Pget_fapl_direct: info not pinned"); + + if ((retVal = H5Pget_fapl_direct((hid_t)fapl_id, &alignment, &block_size, &cbuf_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jlong)alignment; + theArray[1] = (jlong)block_size; + theArray[2] = (jlong)cbuf_size; + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, info, theArray, (retVal < 0) ? JNI_ABORT : 0); +#else + UNUSED(env); + UNUSED(fapl_id); + UNUSED(info); +#endif + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_family + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family + (JNIEnv *env, jclass clss, jlong plist, jlong memb_size, jlong memb_plist) +{ + long ms = (long)memb_size; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fapl_family((hid_t)plist, (hsize_t)ms, (hid_t)memb_plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_family + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family + (JNIEnv *env, jclass clss, jlong tid, jlongArray memb_size, jlongArray memb_plist) +{ + jboolean isCopy; + hsize_t *sa = NULL; + size_t i; + jlong *sizeArray = NULL; + jlong *plistArray = NULL; + jsize rank; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == memb_size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_family: memb_size is NULL"); + if (NULL == memb_plist) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_family: memb_plist is NULL"); + + PIN_LONG_ARRAY(ENVONLY, memb_size, sizeArray, &isCopy, "H5Pget_family: sizeArray not pinned"); + + if ((rank = ENVPTR->GetArrayLength(ENVONLY, memb_size)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_family: memb_size array length < 0"); + } + + if (NULL == (sa = (hsize_t *) HDmalloc((size_t) rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_family: memory allocation failed"); + + PIN_LONG_ARRAY(ENVONLY, memb_plist, plistArray, &isCopy, "H5Pget_family: plistArray not pinned"); + + if ((status = H5Pget_fapl_family((hid_t)tid, sa, (hid_t *)plistArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (size_t) rank; i++) + sizeArray[i] = (jlong)sa[i]; + +done: + if (plistArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_plist, plistArray, (status < 0) ? JNI_ABORT : 0); + if (sa) + HDfree(sa); + if (sizeArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_size, sizeArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_family_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1family_1offset + (JNIEnv *env, jclass clss, jlong fapl_id, jlong offset) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_family_offset((hid_t)fapl_id, (hsize_t)offset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1family_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_family_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1family_1offset + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + hsize_t offset = 0; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pget_family_offset((hid_t)fapl_id, &offset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)offset; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1family_1offset */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_log + * Signature: (JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log + (JNIEnv *env, jclass clss, jlong fapl_id, jstring logfile, jlong flags, jlong buf_size) +{ + const char *pLogfile = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, logfile, pLogfile, NULL, "H5Pset_fapl_log: log file name not pinned"); + + if ((retVal = H5Pset_fapl_log((hid_t)fapl_id, pLogfile, (unsigned long long)flags, (size_t)buf_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (pLogfile) + UNPIN_JAVA_STRING(ENVONLY, logfile, pLogfile); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log */ + +/* + * TODO: H5Pset_fapl_mpio + */ + +/* + * TODO: H5Pget_fapl_mpio + */ + +/* + * TODO: H5Pset_fapl_mpiposix + */ + +/* + * TODO: H5Pget_fapl_mpiposix + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_multi + * Signature: (J[I[J[Ljava/lang/String;[JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi + (JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, jboolean relax) +{ + const char * const *mName = NULL; + jboolean isCopy; + jboolean bb; + jobject o; + jstring rstring; + jclass Sjc; + size_t i; + jlong *thefaplArray = NULL; + jlong *theaddrArray = NULL; + jint *themapArray = NULL; + char *member_name[H5FD_MEM_NTYPES]; + herr_t status = FAIL; + + UNUSED(clss); + + HDmemset(member_name, 0, H5FD_MEM_NTYPES * sizeof(char *)); + + if (memb_map) + PIN_INT_ARRAY(ENVONLY, memb_map, themapArray, &isCopy, "H5Pset_fapl_multi: memb_map not pinned"); + if (memb_fapl) + PIN_LONG_ARRAY(ENVONLY, memb_fapl, thefaplArray, &isCopy, "H5Pset_fapl_multi: memb_fapl not pinned"); + if (memb_addr) + PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pset_fapl_multi: memb_addr not pinned"); + + if (memb_name) { + jstring obj; + + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + const char *utf8 = NULL; + size_t str_len; + + if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) memb_name, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + member_name[i] = NULL; + continue; + } + + /* + * length = ENVPTR->GetStringUTFLength(ENVONLY, obj); + * CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + */ + + PIN_JAVA_STRING(ENVONLY, obj, utf8, NULL, "H5Pset_fapl_multi: string not pinned"); + + str_len = HDstrlen(utf8); + + if (NULL == (member_name[i] = (char *) HDmalloc(str_len + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); + + HDstrncpy(member_name[i], utf8, str_len + 1); + + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); + utf8 = NULL; + + ENVPTR->DeleteLocalRef(ENVONLY, obj); + } + + mName = (const char * const *)member_name; + } + + if ((status = H5Pset_fapl_multi((hid_t)tid, (const H5FD_mem_t *)themapArray, (const hid_t *)thefaplArray, + mName, (const haddr_t *)theaddrArray, (hbool_t)relax)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (memb_name && mName) { + if (NULL == (Sjc = ENVPTR->FindClass(ENVONLY, "java/lang/String"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); + } + + if (NULL == (o = ENVPTR->GetObjectArrayElement(ENVONLY, memb_name, (jsize) i))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* + * If the string object was NULL, skip it. + */ + ENVPTR->DeleteLocalRef(ENVONLY, rstring); + continue; + } + + if (JNI_TRUE == (bb = ENVPTR->IsInstanceOf(ENVONLY, o, Sjc))) { + ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)rstring); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + + ENVPTR->DeleteLocalRef(ENVONLY, o); + ENVPTR->DeleteLocalRef(ENVONLY, rstring); + + HDfree(member_name[i]); + member_name[i] = NULL; + } + } + +done: + h5str_array_free(member_name, H5FD_MEM_NTYPES); + if (theaddrArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, (status < 0) ? JNI_ABORT : 0); + if (thefaplArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_fapl, thefaplArray, (status < 0) ? JNI_ABORT : 0); + if (themapArray) + UNPIN_INT_ARRAY(ENVONLY, memb_map, themapArray, (status < 0) ? JNI_ABORT : 0); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_multi + * Signature: (J[I[J[Ljava/lang/String;[J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi + (JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, + jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr) +{ + jboolean isCopy; + jstring str; + herr_t status = FAIL; + size_t i; + jlong *thefaplArray = NULL; + jlong *theaddrArray = NULL; + jint *themapArray = NULL; + char **mName = NULL; + int relax = 0; + int retVal = 0; + + UNUSED(clss); + + if (memb_map) + PIN_INT_ARRAY(ENVONLY, memb_map, themapArray, &isCopy, "H5Pget_fapl_multi: memb_map not pinned"); + if (memb_fapl) + PIN_LONG_ARRAY(ENVONLY, memb_fapl, thefaplArray, &isCopy, "H5Pget_fapl_multi: memb_fapl not pinned"); + if (memb_addr) + PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pget_fapl_multi: memb_addr not pinned"); + if (memb_name) + if (NULL == (mName = (char **) HDcalloc(H5FD_MEM_NTYPES, sizeof(*mName)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: memory allocation failed"); + + if ((status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t *)themapArray, (hid_t *)thefaplArray, + mName, (haddr_t *)theaddrArray, (hbool_t *)&relax)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (memb_name && mName) { + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (mName[i]) { + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, mName[i]))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_fapl_multi: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, memb_name, (jsize) i, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, str); + } + } + } + + retVal = (relax != 0); + +done: + h5str_array_free(mName, H5FD_MEM_NTYPES); + if (theaddrArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, (status < 0) ? JNI_ABORT : 0); + if (thefaplArray) + UNPIN_LONG_ARRAY(ENVONLY, memb_fapl, thefaplArray, (status < 0) ? JNI_ABORT : 0); + if (themapArray) + UNPIN_INT_ARRAY(ENVONLY, memb_map, themapArray, (status < 0) ? JNI_ABORT : 0); + + return (jboolean)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi */ + +/* + * TODO: H5Pset_multi_type + */ + +/* + * TODO: H5Pget_multi_type + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_split + * Signature: (JLjava/lang/String;JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split + (JNIEnv *env, jclass clss, jlong fapl_id, jstring metaext, jlong meta_pl_id, jstring rawext, jlong raw_pl_id) +{ + const char *mstr = NULL; + const char *rstr = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, metaext, mstr, NULL, "H5Pset_fapl_split: metaext not pinned"); + PIN_JAVA_STRING(ENVONLY, rawext, rstr, NULL, "H5Pset_fapl_split: rawext not pinned"); + + if ((retVal = H5Pset_fapl_split((hid_t)fapl_id, mstr, (hid_t)meta_pl_id, rstr, (hid_t)raw_pl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (rstr) + UNPIN_JAVA_STRING(ENVONLY, rawext, rstr); + if (mstr) + UNPIN_JAVA_STRING(ENVONLY, metaext, mstr); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_sec2 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fapl_sec2((hid_t) fapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_stdio + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_fapl_stdio((hid_t) fapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_windows + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + +#ifdef H5_HAVE_WINDOWS + if ((retVal = H5Pset_fapl_windows((hid_t) fapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: +#else + UNUSED(env); + UNUSED(fapl_id); +#endif + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows */ + +/* + * TODO: H5Pset_file_image + */ + +/* + * TODO: H5Pget_file_image + */ + +/* + * TODO: H5Pset_file_image_callbacks + */ + +/* + * TODO: H5Pget_file_image_callbacks + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_meta_block_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size + (JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + long sz = (long)size; + + UNUSED(clss); + + if (H5Pset_meta_block_size((hid_t)plist, (hsize_t)sz) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_meta_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size + (JNIEnv *env, jclass clss, jlong plist) +{ + hsize_t s = 0; + + UNUSED(clss); + + if (H5Pget_meta_block_size((hid_t)plist, &s) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size */ + +/* + * TODO: H5Pset_page_buffer_size + */ + +/* + * TODO: H5Pget_page_buffer_size + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sieve_buf_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size + (JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + size_t sz = (size_t)size; + + UNUSED(clss); + + if (H5Pset_sieve_buf_size((hid_t)plist, (size_t)sz) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sieve_buf_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size + (JNIEnv *env, jclass clss, jlong plist) +{ + size_t s = 0; + + UNUSED(clss); + + if (H5Pget_sieve_buf_size((hid_t)plist, &s) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alignment + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alignment + (JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment) +{ + long thr = (long)threshold; + long align = (long)alignment; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_alignment((hid_t)plist, (hsize_t)thr, (hsize_t)align)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1alignment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alignment + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alignment + (JNIEnv *env, jclass clss, jlong plist, jlongArray alignment) +{ + jboolean isCopy; + hsize_t t = 0; + hsize_t a = 0; + jsize arrLen; + jlong *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == alignment) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_alignment: input alignment is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, alignment)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_alignment: alignment array length < 0"); + } + if (arrLen < 2) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_alignment: alignment input array < 2"); + + PIN_LONG_ARRAY(ENVONLY, alignment, theArray, &isCopy, "H5Pget_alignment: input array not pinned"); + + if ((status = H5Pget_alignment((hid_t)plist, &t, &a)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jlong)t; + theArray[1] = (jlong)a; + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, alignment, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1alignment */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_cache + * Signature: (JIJJD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1cache + (JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts, + jlong rdcc_nbytes, jdouble rdcc_w0) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts, + (size_t)rdcc_nbytes, (double) rdcc_w0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_cache + * Signature: (J[I[J[J[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1cache + (JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts, + jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +{ + jboolean isCopy; + jdouble *w0Array = NULL; + jlong *rdcc_nelmtsArray = NULL; + jlong *nbytesArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + UNUSED(mdc_nelmts); + + if (NULL != rdcc_w0) + PIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, &isCopy, "H5Pget_cache: rdcc_w0 array not pinned"); + if (NULL != rdcc_nelmts) + PIN_LONG_ARRAY(ENVONLY, rdcc_nelmts, rdcc_nelmtsArray, &isCopy, "H5Pget_cache: rdcc_nelmts array not pinned"); + if (NULL != rdcc_nbytes) + PIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, &isCopy, "H5Pget_cache: nbytesArray array not pinned"); + + { + /* direct cast (size_t *)variable fails on 32-bit environment */ + long long rdcc_nelmts_temp = *rdcc_nelmtsArray; + long long nbytes_temp = *nbytesArray; + size_t rdcc_nelmts_t = (size_t) rdcc_nelmts_temp; + size_t nbytes_t = (size_t) nbytes_temp; + + if ((status = H5Pget_cache((hid_t)plist, (int *)NULL, &rdcc_nelmts_t, + &nbytes_t, (double *)w0Array)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + *rdcc_nelmtsArray = (jlong)rdcc_nelmts_t; + *nbytesArray = (jlong)nbytes_t; + } /* end direct cast special */ + +done: + if (nbytesArray) + UNPIN_LONG_ARRAY(ENVONLY, rdcc_nbytes, nbytesArray, (status < 0) ? JNI_ABORT : 0); + if (rdcc_nelmtsArray) + UNPIN_LONG_ARRAY(ENVONLY, rdcc_nelmts, rdcc_nelmtsArray, (status < 0) ? JNI_ABORT : 0); + if (w0Array) + UNPIN_DOUBLE_ARRAY(ENVONLY, rdcc_w0, w0Array, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1cache */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_file_cache_size + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size + (JNIEnv *env, jclass clss, jlong plist, jint size) +{ + unsigned sz = (unsigned)size; + + UNUSED(clss); + + if (H5Pset_elink_file_cache_size((hid_t)plist, (unsigned)sz) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_file_cache_size + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size + (JNIEnv *env, jclass clss, jlong plist) +{ + unsigned s = 0; + + UNUSED(clss); + + if (H5Pget_elink_file_cache_size((hid_t)plist, &s) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_evict_on_close + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close + (JNIEnv *env, jclass clss, jlong fapl_id, jboolean evict_on_close) +{ + hbool_t evict_on_close_val = FALSE; + herr_t retVal = FAIL; + + UNUSED(clss); + + evict_on_close_val = (evict_on_close == JNI_TRUE) ? TRUE : FALSE; + + if ((retVal = H5Pset_evict_on_close((hid_t)fapl_id, (hbool_t)evict_on_close_val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_evict_on_close + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + hbool_t evict_on_close_val = FALSE; + jboolean bval = JNI_FALSE; + + UNUSED(clss); + + if (H5Pget_evict_on_close((hid_t)fapl_id, (hbool_t *)&evict_on_close_val) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (evict_on_close_val == TRUE) ? JNI_TRUE : JNI_FALSE; + +done: + return bval; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_metadata_read_attempts + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts + (JNIEnv *env, jclass clss, jlong plist_id, jlong attempts) +{ + UNUSED(clss); + + if (attempts <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_metadata_read_attempts: attempts <= 0"); + + if (H5Pset_metadata_read_attempts((hid_t)plist_id, (unsigned)attempts) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_metadata_read_attempts + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts + (JNIEnv *env, jclass clss, jlong plist_id) +{ + unsigned attempts = 0; + + UNUSED(clss); + + if (H5Pget_metadata_read_attempts((hid_t)plist_id, &attempts) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong) attempts; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_config + * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config + (JNIEnv *env, jclass clss, jlong plist, jobject cache_config) +{ + H5AC_cache_config_t cacheinfo; + const char *str = NULL; + jfieldID fid; + jstring j_str; + jclass cls; + jint flash_incr_mode; + jint incr_mode; + jint decr_mode; + herr_t status = FAIL; + + UNUSED(clss); + + HDmemset(&cacheinfo, 0, sizeof(H5AC_cache_config_t)); + + if (NULL == (cls = ENVPTR->GetObjectClass(ENVONLY, cache_config))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "version", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.version = ENVPTR->GetIntField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "rpt_fcn_enabled", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.rpt_fcn_enabled = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "open_trace_file", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.open_trace_file = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "close_trace_file", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.close_trace_file = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "trace_file_name", "Ljava/lang/String;"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (j_str = (jstring)ENVPTR->GetObjectField(ENVONLY, cache_config, fid))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_mdc_config: cache_config not pinned"); + + HDstrncpy(cacheinfo.trace_file_name, str, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + + UNPIN_JAVA_STRING(ENVONLY, j_str, str); + str = NULL; + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "evictions_enabled", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.evictions_enabled = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "set_initial_size", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.set_initial_size = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "initial_size", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.initial_size = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "min_clean_fraction", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.min_clean_fraction = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "max_size", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.max_size = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "min_size", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.min_size = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "epoch_length", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.epoch_length = (long int)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "incr_mode", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + incr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_incr_mode) */ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + cacheinfo.incr_mode = (enum H5C_cache_incr_mode) incr_mode; + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "lower_hr_threshold", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.lower_hr_threshold = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "increment", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.increment = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "apply_max_increment", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.apply_max_increment = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "max_increment", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.max_increment = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "flash_incr_mode", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + flash_incr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_flash_incr_mode) */ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + cacheinfo.flash_incr_mode = (enum H5C_cache_flash_incr_mode) flash_incr_mode; + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "flash_multiple", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.flash_multiple = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "flash_threshold", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.flash_threshold = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "decr_mode", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + decr_mode = ENVPTR->GetIntField(ENVONLY, cache_config, fid); /*(enum H5C_cache_decr_mode) */ + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + cacheinfo.decr_mode = (enum H5C_cache_decr_mode) decr_mode; + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "upper_hr_threshold", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.upper_hr_threshold = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "decrement", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.decrement = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "apply_max_decrement", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.apply_max_decrement = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "max_decrement", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.max_decrement = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "epochs_before_eviction", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.epochs_before_eviction = ENVPTR->GetIntField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "apply_empty_reserve", "Z"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.apply_empty_reserve = ENVPTR->GetBooleanField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "empty_reserve", "D"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.empty_reserve = ENVPTR->GetDoubleField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "dirty_bytes_threshold", "J"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.dirty_bytes_threshold = (size_t)ENVPTR->GetLongField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "metadata_write_strategy", "I"))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + cacheinfo.metadata_write_strategy = ENVPTR->GetIntField(ENVONLY, cache_config, fid); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if ((status = H5Pset_mdc_config((hid_t)plist, &cacheinfo)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (str) + UNPIN_JAVA_STRING(ENVONLY, j_str, str); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_config + * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config + (JNIEnv *env, jclass clss, jlong plist) +{ + H5AC_cache_config_t cacheinfo; + jstring j_str = NULL; + jvalue args[30]; + herr_t status = FAIL; + jobject ret_obj = NULL; + + UNUSED(clss); + + HDmemset(&cacheinfo, 0, sizeof(H5AC_cache_config_t)); + cacheinfo.version = H5AC__CURR_CACHE_CONFIG_VERSION; + + if ((status = H5Pget_mdc_config((hid_t)plist, &cacheinfo)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + args[0].i = cacheinfo.version; + args[1].z = cacheinfo.rpt_fcn_enabled; + args[2].z = cacheinfo.open_trace_file; + args[3].z = cacheinfo.close_trace_file; + + if (NULL != cacheinfo.trace_file_name) { + if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, cacheinfo.trace_file_name))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_config: out of memory - unable to construct string from UTF characters"); + } + } + + args[4].l = j_str; + args[5].z = cacheinfo.evictions_enabled; + args[6].z = cacheinfo.set_initial_size; + args[7].j = (jlong)cacheinfo.initial_size; + args[8].d = cacheinfo.min_clean_fraction; + args[9].j = (jlong)cacheinfo.max_size; + args[10].j = (jlong)cacheinfo.min_size; + args[11].j = cacheinfo.epoch_length; + args[12].i = cacheinfo.incr_mode; + args[13].d = cacheinfo.lower_hr_threshold; + args[14].d = cacheinfo.increment; + args[15].z = cacheinfo.apply_max_increment; + args[16].j = (jlong)cacheinfo.max_increment; + args[17].i = cacheinfo.flash_incr_mode; + args[18].d = cacheinfo.flash_multiple; + args[19].d = cacheinfo.flash_threshold; + args[20].i = cacheinfo.decr_mode; + args[21].d = cacheinfo.upper_hr_threshold; + args[22].d = cacheinfo.decrement; + args[23].z = cacheinfo.apply_max_decrement; + args[24].j = (jlong)cacheinfo.max_decrement; + args[25].i = cacheinfo.epochs_before_eviction; + args[26].z = cacheinfo.apply_empty_reserve; + args[27].d = cacheinfo.empty_reserve; + args[28].j = (jlong)cacheinfo.dirty_bytes_threshold; + args[29].i = cacheinfo.metadata_write_strategy; + + CALL_CONSTRUCTOR(ENVONLY, "hdf/hdf5lib/structs/H5AC_cache_config_t", "(IZZZLjava/lang/String;ZZJDJJJIDDZJIDDIDDZJIZDJI)V", args, ret_obj); + +done: + return ret_obj; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config */ + +/* + * TODO: H5Pset_mdc_image_config + */ + +/* + * TODO: H5Pget_mdc_image_config + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_log_options + * Signature: (JZLjava/lang/String;Z)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options + (JNIEnv *env, jclass clss, jlong fapl_id, jboolean is_enabled, jstring location, jboolean start_on_access) +{ + const char *locStr = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, location, locStr, NULL, "H5Pset_mdc_log_options: location string not pinned"); + + if ((retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, locStr, (hbool_t)start_on_access)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (locStr) + UNPIN_JAVA_STRING(ENVONLY, location, locStr); +} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_log_options + * Signature: (J[Z)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options + (JNIEnv *env, jclass clss, jlong fapl_id, jbooleanArray mdc_log_options) +{ + jboolean isCopy; + jboolean *mdc_log_options_ptr = NULL; + hbool_t is_enabled; + hbool_t start_on_access; + ssize_t status = -1; + size_t location_size; + jsize arrLen; + char *lname = NULL; + jstring str = NULL; + + UNUSED(clss); + + if (NULL == mdc_log_options) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: mdc_log_options is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, mdc_log_options)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: mdc_log_options array length < 0"); + } + if (arrLen < 2) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: length of mdc_log_options < 2"); + + PIN_BOOL_ARRAY(ENVONLY, mdc_log_options, mdc_log_options_ptr, &isCopy, "H5Pget_mdc_log_options: mdc_log_options array not pinned"); + + /* get the length of the filename */ + if (H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, NULL, &location_size, &start_on_access) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!location_size) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_mdc_log_options: location_size is 0"); + + location_size++; /* add extra space for the null terminator */ + if (NULL == (lname = (char *) HDmalloc(sizeof(char) * location_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: memory allocation failed"); + + if ((status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + lname[location_size - 1] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, lname))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_mdc_log_options: out of memory - unable to construct string from UTF characters"); + } + + mdc_log_options_ptr[0] = (jboolean)is_enabled; + mdc_log_options_ptr[1] = (jboolean)start_on_access; + +done: + if (lname) + HDfree(lname); + if (mdc_log_options_ptr) + UNPIN_BOOL_ARRAY(ENVONLY, mdc_log_options, mdc_log_options_ptr, (status < 0) ? JNI_ABORT : 0); + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options */ + +/* + * TODO: H5Pset_all_coll_metadata_ops + */ + +/* + * TODO: H5Pget_all_coll_metadata_ops + */ + +/* + * TODO: H5Pset_coll_metadata_write + */ + +/* + * TODO: H5Pget_coll_metadata_write + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_gc_references + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1gc_1references + (JNIEnv *env, jclass clss, jlong fapl_id, jboolean gc_ref) +{ + unsigned gc_ref_val = 0; + herr_t retVal = FAIL; + + UNUSED(clss); + + gc_ref_val = (gc_ref == JNI_TRUE) ? 1 : 0; + + if ((retVal = H5Pset_gc_references((hid_t)fapl_id, gc_ref_val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1gc_1references */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_gc_references + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1gc_1references + (JNIEnv *env, jclass clss, jlong fapl_id) +{ + unsigned gc_ref_val = 0; + jboolean bval = JNI_FALSE; + + UNUSED(clss); + + if (H5Pget_gc_references((hid_t)fapl_id, (unsigned *)&gc_ref_val) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (gc_ref_val == 1) ? JNI_TRUE : JNI_FALSE; + +done: + return bval; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1gc_1references */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_small_data_block_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size + (JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + long sz = (long)size; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_small_data_block_size((hid_t)plist, (hsize_t)sz)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_small_data_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size + (JNIEnv *env, jclass clss, jlong plist) +{ + hsize_t s = 0; + + UNUSED(clss); + + if (H5Pget_small_data_block_size((hid_t)plist, &s) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)s; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_libver_bounds + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds + (JNIEnv *env, jclass clss, jlong fapl_id, jint low, jint high) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_libver_bounds((hid_t)fapl_id, (H5F_libver_t)low, (H5F_libver_t)high)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_libver_bounds + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds + (JNIEnv *env, jclass clss, jlong fapl_id, jintArray libver) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == libver) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_libver_bounds: libversion bounds is NULL"); + + PIN_INT_ARRAY(ENVONLY, libver, theArray, &isCopy, "H5Pget_libver_bounds: input not pinned"); + + if ((retVal = H5Pget_libver_bounds((hid_t)fapl_id, (H5F_libver_t *)&(theArray[0]), (H5F_libver_t *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, libver, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds */ + +/* + * TODO: H5Pset_object_flush_cb + */ + +/* + * TODO: H5Pget_object_flush_cb + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pFAPLImp.h b/java/src/jni/h5pFAPLImp.h new file mode 100644 index 0000000..28b1d95 --- /dev/null +++ b/java/src/jni/h5pFAPLImp.h @@ -0,0 +1,501 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PFAPL +#define _Included_hdf_hdf5lib_H5_H5PFAPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * TODO: H5Pset_driver + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_driver + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1driver +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pget_driver_info + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fclose_degree + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fclose_degree + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_core + * Signature: (JJZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core +(JNIEnv *, jclass, jlong, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_core + * Signature: (J[J[Z)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core +(JNIEnv *, jclass, jlong, jlongArray, jbooleanArray); + +/* + * TODO: H5Pset_core_write_tracking + */ + +/* + * TODO: H5Pget_core_write_tracking + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_direct + * Signature: (JJJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct +(JNIEnv *, jclass, jlong, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_direct + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_family + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family +(JNIEnv *, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_family + * Signature: (J[J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family +(JNIEnv *, jclass, jlong, jlongArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_family_offset + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1family_1offset +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_family_offset + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1family_1offset +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_log + * Signature: (JLjava/lang/String;JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log +(JNIEnv *, jclass, jlong, jstring, jlong, jlong); + +/* + * TODO: H5Pset_fapl_mpio + */ + +/* + * TODO: H5Pget_fapl_mpio + */ + +/* + * TODO: H5Pset_fapl_mpiposix + */ + +/* + * TODO: H5Pget_fapl_mpiposix + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_multi + * Signature: (J[I[J[Ljava/lang/String;[JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_fapl_multi + * Signature: (J[I[J[Ljava/lang/String;[J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray); + +/* + * TODO: H5Pset_multi_type + */ + +/* + * TODO: H5Pget_multi_type + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_split + * Signature: (JLjava/lang/String;JLjava/lang/String;J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split +(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_sec2 + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_stdio + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_fapl_windows + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pset_file_image + */ + +/* + * TODO: H5Pget_file_image + */ + +/* + * TODO: H5Pset_file_image_callbacks + */ + +/* + * TODO: H5Pget_file_image_callbacks + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_meta_block_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_meta_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pset_page_buffer_size + */ + +/* + * TODO: H5Pget_page_buffer_size + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sieve_buf_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sieve_buf_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_alignment + * Signature: (JJJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1alignment +(JNIEnv *, jclass, jlong, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_alignment + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1alignment +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_cache + * Signature: (JIJJD)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1cache +(JNIEnv *, jclass, jlong, jint, jlong, jlong, jdouble); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_cache + * Signature: (J[I[J[J[D)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1cache +(JNIEnv *, jclass, jlong, jintArray, jlongArray, jlongArray, jdoubleArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_file_cache_size + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_file_cache_size + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_evict_on_close + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_evict_on_close + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_metadata_read_attempts + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_metadata_read_attempts + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_config + * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config +(JNIEnv *, jclass, jlong, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_config + * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; + */ +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pset_mdc_image_config + */ + +/* + * TODO: H5Pget_mdc_image_config + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_mdc_log_options + * Signature: (JZLjava/lang/String;Z)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options +(JNIEnv *, jclass, jlong, jboolean, jstring, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_mdc_log_options + * Signature: (J[Z)Ljava/lang/String; + */ +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options +(JNIEnv *, jclass, jlong, jbooleanArray); + +/* + * TODO: H5Pset_all_coll_metadata_ops + */ + +/* + * TODO: H5Pget_all_coll_metadata_ops + */ + +/* + * TODO: H5Pset_coll_metadata_write + */ + +/* + * TODO: H5Pget_coll_metadata_write + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_gc_references + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1gc_1references +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_gc_references + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1gc_1references +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_small_data_block_size + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_small_data_block_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_libver_bounds + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_libver_bounds + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds +(JNIEnv *, jclass, jlong, jintArray); + +/* + * TODO: H5Pset_object_flush_cb + */ + +/* + * TODO: H5Pget_object_flush_cb + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PFAPL */ diff --git a/java/src/jni/h5pFCPLImp.c b/java/src/jni/h5pFCPLImp.c new file mode 100644 index 0000000..9c82ba6 --- /dev/null +++ b/java/src/jni/h5pFCPLImp.c @@ -0,0 +1,572 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pFCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_userblock + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1userblock + (JNIEnv *env, jclass clss, jlong plist, jlong size) +{ + long sz = (long) size; + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_userblock((hid_t)plist, (hsize_t)sz)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1userblock */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_userblock + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1userblock + (JNIEnv *env, jclass clss, jlong plist, jlongArray size) +{ + jboolean isCopy; + hsize_t s; + jlong *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_userblock: size is NULL"); + + PIN_LONG_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_userblock: size not pinned"); + + if ((status = H5Pget_userblock((hid_t)plist, &s)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jlong)s; + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, size, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1userblock */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sizes + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sizes + (JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_sizes((hid_t)plist, (size_t)sizeof_addr, (size_t)sizeof_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sizes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sizes + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sizes + (JNIEnv *env, jclass clss, jlong plist, jlongArray size) +{ + jboolean isCopy; + jlong *theArray = NULL; + jsize arrLen; + size_t ss; + size_t sa; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_sizes: size is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, size)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_sizes: size array length < 0"); + } + if (arrLen < 2) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_sizes: size input array < 2 elements"); + + PIN_LONG_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_sizes: size not pinned"); + + if ((status = H5Pget_sizes((hid_t)plist, &sa, &ss)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + theArray[0] = (jlong)sa; + theArray[1] = (jlong)ss; + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, size, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sizes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sym_k + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sym_1k + (JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_sym_k((hid_t)plist, (unsigned)ik, (unsigned)lk)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1sym_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sym_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sym_1k + (JNIEnv *env, jclass clss, jlong plist, jintArray size) +{ + jboolean isCopy; + jsize arrLen; + jint *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_sym_k: size is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, size)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_sym_k: size array length < 0"); + } + if (arrLen < 2) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_sym_k: size < 2 elements"); + + PIN_INT_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_sym_k: size not pinned"); + + if ((status = H5Pget_sym_k((hid_t)plist, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_LONG_ARRAY(ENVONLY, size, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1sym_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_istore_k + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1istore_1k + (JNIEnv *env, jclass clss, jlong plist, jint ik) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_istore_k((hid_t)plist, (unsigned)ik)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1istore_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_istore_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1istore_1k + (JNIEnv *env, jclass clss, jlong plist, jintArray ik) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == ik) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_store_k: ik is NULL"); + + PIN_INT_ARRAY(ENVONLY, ik, theArray, &isCopy, "H5Pget_store_k: size not pinned"); + + if ((status = H5Pget_istore_k((hid_t)plist, (unsigned *)&(theArray[0]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, ik, theArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1istore_1k */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_page_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size + (JNIEnv *env, jclass clss, jlong fcpl_id, jlong fsp_size) +{ + UNUSED(clss); + + if (H5Pset_file_space_page_size((hid_t)fcpl_id, (hsize_t)fsp_size) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_page_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + hsize_t fsp_size = 0; + + UNUSED(clss); + + if (H5Pget_file_space_page_size((hid_t)fcpl_id, &fsp_size) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)fsp_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_strategy + * Signature: (JIZJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy + (JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jboolean persist, jlong threshold) +{ + UNUSED(clss); + + if (H5Pset_file_space_strategy((hid_t)fcpl_id, (H5F_fspace_strategy_t)strategy, (hbool_t)persist, (hsize_t)threshold) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_file_space_strategy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy + * Signature: (J[Z[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy + (JNIEnv *env, jclass clss, jlong fcpl_id, jbooleanArray persist, jlongArray threshold) +{ + H5F_fspace_strategy_t thestrategy = H5F_FSPACE_STRATEGY_FSM_AGGR; /* Library default */ + jboolean isCopy; + jboolean *persistArray = NULL; + jlong *thresholdArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (persist) + PIN_BOOL_ARRAY(ENVONLY, persist, persistArray, &isCopy, "H5Pget_file_space: persist not pinned"); + if (threshold) + PIN_LONG_ARRAY(ENVONLY, threshold, thresholdArray, &isCopy, "H5Pget_file_space: threshold not pinned"); + + if ((status = H5Pget_file_space_strategy((hid_t)fcpl_id, &thestrategy, (hbool_t *)persistArray, (hsize_t *)thresholdArray)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (thresholdArray) + UNPIN_LONG_ARRAY(ENVONLY, threshold, thresholdArray, (status < 0) ? JNI_ABORT : 0); + if (persistArray) + UNPIN_BOOL_ARRAY(ENVONLY, persist, persistArray, (status < 0) ? JNI_ABORT : 0); + + return (jint)thestrategy; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_persist + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + hbool_t persist = FALSE; + herr_t status = FAIL; + + UNUSED(clss); + + if ((status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, &persist, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jboolean)persist; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_threshold + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + hsize_t threshold = 0; + herr_t status = FAIL; + + UNUSED(clss); + + if ((status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, NULL, &threshold)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)threshold; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1threshold */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_nindexes + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes + (JNIEnv *env, jclass clss, jlong plist_id, jint nindexes) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if (nindexes > H5O_SHMESG_MAX_NINDEXES) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_nindexes: number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); + + if ((retVal = H5Pset_shared_mesg_nindexes((hid_t)plist_id, (unsigned)nindexes)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_nindexes + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes + (JNIEnv *env, jclass clss, jlong fcpl_id) +{ + unsigned nindexes; + + UNUSED(clss); + + if (H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)nindexes; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_index + * Signature: (JIII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index + (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, + jint mesg_type_flags, jint min_mesg_size) +{ + unsigned nindexes; /* Number of SOHM indexes */ + herr_t retVal = FAIL; + + UNUSED(clss); + + /* Check arguments */ + if ((unsigned) mesg_type_flags > H5O_SHMESG_ALL_FLAG) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_index: unrecognized flags in mesg_type_flags"); + + /* Read the current number of indexes */ + if (H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Range check */ + if ((unsigned) index_num >= nindexes) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_index: index_num is too large; no such index"); + + if ((retVal = H5Pset_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned) mesg_type_flags, (unsigned) min_mesg_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_index + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index + (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, jintArray mesg_info) +{ + jboolean isCopy; + unsigned nindexes; /* Number of SOHM indexes */ + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == mesg_info) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_shared_mesg_index: mesg_info is NULL"); + + /* Read the current number of indexes */ + if (H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Range check */ + if ((unsigned) index_num >= nindexes) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pget_shared_mesg_index: index_num is too large; no such index"); + + PIN_INT_ARRAY(ENVONLY, mesg_info, theArray, &isCopy, "H5Pget_shared_mesg_index: input not pinned"); + + if ((retVal = H5Pget_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, mesg_info, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change + (JNIEnv *env, jclass clss, jlong fcpl_id, jint max_list, jint min_btree) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + /* Check that values are sensible. The min_btree value must be no greater + * than the max list plus one. + * + * Range check to make certain they will fit into encoded form. + */ + + if (max_list + 1 < min_btree) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: minimum B-tree value is greater than maximum list value"); + if (max_list > H5O_SHMESG_MAX_LIST_SIZE) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + if (min_btree > H5O_SHMESG_MAX_LIST_SIZE) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_shared_mesg_phase_change: min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); + + if ((retVal = H5Pset_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned)max_list, (unsigned)min_btree)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change + (JNIEnv *env, jclass clss, jlong fcpl_id, jintArray size) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == size) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_shared_mesg_phase_change: size is NULL"); + + PIN_INT_ARRAY(ENVONLY, size, theArray, &isCopy, "H5Pget_shared_mesg_phase_change: input not pinned"); + + if ((retVal = H5Pget_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, size, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pFCPLImp.h b/java/src/jni/h5pFCPLImp.h new file mode 100644 index 0000000..57fcae8 --- /dev/null +++ b/java/src/jni/h5pFCPLImp.h @@ -0,0 +1,207 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PFCPL +#define _Included_hdf_hdf5lib_H5_H5PFCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_userblock + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1userblock +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_userblock + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1userblock +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sizes + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sizes +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sizes + * Signature: (J[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sizes +(JNIEnv *, jclass, jlong, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_sym_k + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1sym_1k +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_sym_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1sym_1k +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_istore_k + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1istore_1k +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_istore_k + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1istore_1k +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_page_size + * Signature: (JJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_page_size + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_file_space_strategy + * Signature: (JIZJ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy +(JNIEnv *, jclass, jlong, jint, jboolean, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy + * Signature: (J[Z[J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy +(JNIEnv *, jclass, jlong, jbooleanArray, jlongArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_persist + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_file_space_strategy_threshold + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_nindexes + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_nindexes + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_index + * Signature: (JIII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index +(JNIEnv *, jclass, jlong, jint, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_index + * Signature: (JI[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index +(JNIEnv *, jclass, jlong, jint, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_shared_mesg_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_shared_mesg_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PFCPL */ diff --git a/java/src/jni/h5pGAPLImp.c b/java/src/jni/h5pGAPLImp.c new file mode 100644 index 0000000..9540387 --- /dev/null +++ b/java/src/jni/h5pGAPLImp.c @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pGAPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pGAPLImp.h b/java/src/jni/h5pGAPLImp.h new file mode 100644 index 0000000..73ad4a8 --- /dev/null +++ b/java/src/jni/h5pGAPLImp.h @@ -0,0 +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 * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PGAPL +#define _Included_hdf_hdf5lib_H5_H5PGAPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PGAPL */ diff --git a/java/src/jni/h5pGCPLImp.c b/java/src/jni/h5pGCPLImp.c new file mode 100644 index 0000000..2ba1c7d --- /dev/null +++ b/java/src/jni/h5pGCPLImp.c @@ -0,0 +1,227 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pGCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_local_heap_size_hint + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint + (JNIEnv *env, jclass clss, jlong gcpl_id, jlong size_hint) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_local_heap_size_hint((hid_t)gcpl_id, (size_t)size_hint)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_local_heap_size_hint + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint + (JNIEnv *env, jclass clss, jlong gcpl_id) +{ + size_t size_hint = 0; + + UNUSED(clss); + + if (H5Pget_local_heap_size_hint((hid_t)gcpl_id, &size_hint) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)size_hint; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order + (JNIEnv *env, jclass clss, jlong gcpl_id, jint crt_order_flags) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_link_creation_order((hid_t)gcpl_id, (unsigned)crt_order_flags)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order + (JNIEnv *env, jclass clss, jlong gcpl_id) +{ + unsigned crt_order_flags; + + UNUSED(clss); + + if (H5Pget_link_creation_order((hid_t)gcpl_id, &crt_order_flags) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)crt_order_flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_est_link_info + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info + (JNIEnv *env, jclass clss, jlong gcpl_id, jint est_num_entries, jint est_name_len) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + /* Range check values */ + if ((est_num_entries > 65535) || (est_name_len > 65535)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_est_link_info: est. name length or number of entries must be < 65536"); + + if ((retVal = H5Pset_est_link_info((hid_t)gcpl_id, (unsigned)est_num_entries, (unsigned)est_name_len)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_est_link_info + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info + (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray link_info) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == link_info) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_est_link_info: link_info is NULL"); + + PIN_INT_ARRAY(ENVONLY, link_info, theArray, &isCopy, "H5Pget_est_link_info: input not pinned"); + + if ((retVal = H5Pget_est_link_info((hid_t)gcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, link_info, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change + (JNIEnv *env, jclass clss, jlong gcpl_id, jint max_compact, jint min_dense) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if (max_compact < min_dense) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_link_phase_change: max compact value must be >= min dense value"); + if (max_compact > 65535) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_link_phase_change: max compact value must be < 65536"); + if (min_dense > 65535) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_link_phase_change: min dense value must be < 65536"); + + if ((retVal = H5Pset_link_phase_change((hid_t)gcpl_id, (unsigned)max_compact, (unsigned)min_dense)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change + (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray links) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == links) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_link_phase_change: links is NULL"); + + PIN_INT_ARRAY(ENVONLY, links, theArray, &isCopy, "H5Pget_link_phase_change: input not pinned"); + + if ((retVal = H5Pget_link_phase_change((hid_t)gcpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, links, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pGCPLImp.h b/java/src/jni/h5pGCPLImp.h new file mode 100644 index 0000000..9c32063 --- /dev/null +++ b/java/src/jni/h5pGCPLImp.h @@ -0,0 +1,99 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PGCPL +#define _Included_hdf_hdf5lib_H5_H5PGCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_local_heap_size_hint + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_local_heap_size_hint + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_est_link_info + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_est_link_info + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_link_phase_change + * Signature: (JII)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_link_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PGCPL */ diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index ac21d1d..bed23c9 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -26,7 +26,11 @@ extern "C" { #include "h5util.h" #include "h5pImp.h" +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ extern JavaVM *jvm; + extern jobject copy_callback; extern jobject close_callback; extern jobject create_callback; @@ -44,17 +48,16 @@ typedef struct _cb_wrapper { /* Local Prototypes */ /********************/ -static herr_t H5P_cls_create_func_cb(hid_t prop_id, void *create_data); -static herr_t H5P_cls_copy_func_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); -static herr_t H5P_cls_close_func_cb(hid_t prop_id, void *close_data); - -static herr_t H5P_prp_create_func_cb(const char *name, size_t size, void *value); -static herr_t H5P_prp_copy_func_cb(const char *name, size_t size, void *value); -static herr_t H5P_prp_close_func_cb(const char *name, size_t size, void *value); -static int H5P_prp_compare_func_cb(void *value1, void *value2, size_t size); -static herr_t H5P_prp_get_func_cb(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P_prp_set_func_cb(hid_t prop_id, const char *name, size_t size, void *value); -static herr_t H5P_prp_delete_func_cb(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P_cls_create_cb(hid_t prop_id, void *create_data); +static herr_t H5P_cls_copy_cb(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); +static herr_t H5P_cls_close_cb(hid_t prop_id, void *close_data); +static herr_t H5P_prp_create_cb(const char *name, size_t size, void *value); +static herr_t H5P_prp_copy_cb(const char *name, size_t size, void *value); +static herr_t H5P_prp_close_cb(const char *name, size_t size, void *value); +static int H5P_prp_compare_cb(void *value1, void *value2, size_t size); +static herr_t H5P_prp_get_cb(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P_prp_set_cb(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P_prp_delete_cb(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P_iterate_cb(hid_t prop_id, const char *name, void *cb_data); @@ -67,37 +70,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcreate (JNIEnv *env, jclass clss, jlong type) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Pcreate((hid_t)type); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Pcreate((hid_t) type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Pcreate */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pclose - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose - (JNIEnv *env, jclass clss, jlong plist) -{ - herr_t retVal = 0; - - if (plist > 0) - retVal = H5Pclose((hid_t)plist); - - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5__1H5Pclose */ - -/* - * Class: hdf_hdf5lib_H5 * Method: H5Pget_class * Signature: (J)J */ @@ -105,12 +90,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Pget_1class (JNIEnv *env, jclass clss, jlong plist) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Pget_class((hid_t) plist); - if (retVal == H5P_ROOT) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Pget_class((hid_t) plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* + * if (retVal == H5P_ROOT) + * H5_LIBRARY_ERROR(ENVONLY); + */ + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Pget_1class */ @@ -123,5834 +115,964 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Pcopy (JNIEnv *env, jclass clss, jlong plist) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Pcopy((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Pcopy((hid_t) plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Pcopy */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_userblock - * Signature: (JJ)I + * Method: H5Pclose + * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1userblock - (JNIEnv *env, jclass clss, jlong plist, jlong size) +Java_hdf_hdf5lib_H5__1H5Pclose + (JNIEnv *env, jclass clss, jlong plist) { - herr_t retVal = -1; - long sz = (long)size; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Pset_userblock((hid_t)plist, (hsize_t)sz); - if (retVal < 0) - h5libraryError(env); + if (plist >= 0) + if ((retVal = H5Pclose((hid_t) plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1userblock */ +} /* end Java_hdf_hdf5lib_H5__1H5Pclose */ /* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_userblock - * Signature: (J[J)I + * TODO: H5Pencode */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1userblock - (JNIEnv *env, jclass clss, jlong plist, jlongArray size) -{ - herr_t status = -1; - jlong *theArray; - jboolean isCopy; - hsize_t s; - - if (size == NULL) { - h5nullArgument(env, "H5Pget_userblock: size is NULL"); - } /* end if */ - else { - theArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_userblock: size not pinned"); - } /* end if */ - else { - status = H5Pget_userblock((hid_t)plist, &s); - - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jlong)s; - ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1userblock */ +/* + * TODO: H5Pdecode + */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sizes - * Signature: (JII)I + * Method: _H5Pcreate_class + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sizes - (JNIEnv *env, jclass clss, jlong plist, jint sizeof_addr, jint sizeof_size) +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class + (JNIEnv *env, jclass clss, jlong parent_class, jstring name, jobject create_op, + jobject create_data, jobject copy_op, jobject copy_data, jobject close_op, jobject close_data) { - herr_t retVal = -1; + const char *cstr = NULL; + hid_t class_id = H5I_INVALID_HID; - retVal = H5Pset_sizes((hid_t)plist, (size_t)sizeof_addr, (size_t)sizeof_size); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1sizes */ + create_callback = create_op; + close_callback = close_op; + copy_callback = copy_op; -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sizes - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sizes - (JNIEnv *env, jclass clss, jlong plist, jlongArray size) -{ - herr_t status = -1; - jlong *theArray; - jboolean isCopy; - size_t ss; - size_t sa; - - if (size == NULL) { - h5nullArgument(env, "H5Pget_sizes: size is NULL"); - } /* end if */ - else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) { - h5badArgument(env, "H5Pget_sizes: size input array < 2 elements"); - } - else { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_sizes: size not pinned"); - } /* end if */ - else { - status = H5Pget_sizes((hid_t)plist, &sa, &ss); - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jlong)sa; - theArray[1] = (jlong)ss; - ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class: class name not pinned"); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1sizes */ + if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, (void *) create_data, + (H5P_cls_copy_func_t)H5P_cls_copy_cb, (void *) copy_data, (H5P_cls_close_func_t)H5P_cls_close_cb, (void *) close_data)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); + + return (jlong)class_id; +} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sym_k - * Signature: (JII)I + * Method: _H5Pcreate_class_nocb + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sym_1k - (JNIEnv *env, jclass clss, jlong plist, jint ik, jint lk) +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb + (JNIEnv *env, jclass clss, jlong parent_class, jstring name) { - herr_t retVal = -1; + const char *cstr = NULL; + hid_t class_id = H5I_INVALID_HID; - retVal = H5Pset_sym_k((hid_t)plist, (unsigned)ik, (unsigned)lk); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1sym_1k */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class_nocb: class name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sym_k - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sym_1k - (JNIEnv *env, jclass clss, jlong plist, jintArray size) -{ - herr_t status = -1; - jint *theArray; - jboolean isCopy; - - if (size == NULL) { - h5nullArgument(env, "H5Pget_sym_k: size is NULL"); - } /* end if */ - else if (ENVPTR->GetArrayLength(ENVPAR size) < 2) { - h5badArgument(env, "H5Pget_sym_k: size < 2 elements"); - } /* end else if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_sym_k: size not pinned"); - } /* end if */ - else { - status = H5Pget_sym_k((hid_t)plist, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1])); - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR size, theArray, 0); - } /* end else */ - } /* end else */ + if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1sym_1k */ +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); + + return (jlong)class_id; +} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_istore_k - * Signature: (JI)I + * Method: H5Pregister2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1istore_1k - (JNIEnv *env, jclass clss, jlong plist, jint ik) +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2 + (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_create, jobject prp_set, jobject prp_get, jobject prp_delete, + jobject prp_copy, jobject prp_cmp, jobject prp_close) { - herr_t retVal = -1; + const char *cstr = NULL; + jboolean isCopy; + herr_t status = FAIL; + jbyte *propValBuf = NULL; - retVal = H5Pset_istore_k((hid_t)plist, (unsigned)ik); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1istore_1k */ + copy_callback = prp_copy; + close_callback = prp_close; + create_callback = prp_create; + compare_callback = prp_cmp; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_istore_k - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1istore_1k - (JNIEnv *env, jclass clss, jlong plist, jintArray ik) -{ - herr_t status = -1; - jint *theArray; - jboolean isCopy; + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2: property name not pinned"); - if (ik == NULL) { - h5nullArgument(env, "H5Pget_store_k: ik is NULL"); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR ik, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_store_k: size not pinned"); - } /* end if */ - else { - status = H5Pget_istore_k((hid_t)plist, (unsigned *)&(theArray[0])); - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR ik, theArray, 0); - } /* end else */ - } /* end else */ + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2: default property value buffer not pinned"); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1istore_1k */ + if ((status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, (H5P_prp_create_func_t)H5P_prp_create_cb, + (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, + (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (propValBuf) + UNPIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, (status < 0) ? JNI_ABORT : 0); + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); +} /* end Java_hdf_hdf5lib_H5_H5Pregister2 */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_layout - * Signature: (JI)I + * Method: H5Pregister2_nocb + * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1layout - (JNIEnv *env, jclass clss, jlong plist, jint layout) +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2_1nocb + (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) { - herr_t retVal = -1; + const char *cstr = NULL; + jboolean isCopy; + herr_t status = FAIL; + jbyte *propValBuf = NULL; - retVal = H5Pset_layout((hid_t)plist, (H5D_layout_t)layout); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1layout */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2_nocb: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_layout - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1layout - (JNIEnv *env, jclass clss, jlong plist) -{ - H5D_layout_t retVal = H5D_LAYOUT_ERROR; + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2_nocb: default property value buffer not pinned"); - retVal = H5Pget_layout((hid_t)plist); - if (retVal == H5D_LAYOUT_ERROR) - h5libraryError(env); + if ((status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1layout */ +done: + if (propValBuf) + UNPIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, (status < 0) ? JNI_ABORT : 0); + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); +} /* end Java_hdf_hdf5lib_H5_H5Pregister2_1nocb */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk - * Signature: (JI[B)I + * Method: H5Pinsert2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk - (JNIEnv *env, jclass clss, jlong plist, jint ndims, jbyteArray dim) +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2 + (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, + jbyteArray def_value, jobject prp_set, jobject prp_get, jobject prp_delete, + jobject prp_copy, jobject prp_cmp, jobject prp_close) { - herr_t status = -1; - jbyte *theArray; - jboolean isCopy; - hsize_t *da; - hsize_t *lp; - jlong *jlp; - size_t i; - size_t rank; - - if (dim == NULL) { - h5nullArgument(env, "H5Pset_chunk: dim array is NULL"); - } /* end if */ - else { - i = (size_t)ENVPTR->GetArrayLength(ENVPAR dim); - rank = i / sizeof(jlong); - if (rank < ndims) { - h5badArgument(env, "H5Pset_chunk: dims array < ndims"); - } /* end if */ - else { - theArray = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR dim, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pset_chunk: dim array not pinned"); - } /* end if */ - else { - da = lp = (hsize_t *)HDmalloc(rank * sizeof(hsize_t)); - if (da == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pset_chunk: dims not converted to hsize_t"); - } /* end if */ - else { - jlp = (jlong *)theArray; - for (i = 0; i < rank; i++) { - *lp = (hsize_t)*jlp; - lp++; - jlp++; - } /* end if */ - - status = H5Pset_chunk((hid_t)plist, (int)ndims, da); - - ENVPTR->ReleaseByteArrayElements(ENVPAR dim, theArray, JNI_ABORT); - HDfree(da); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + const char *cstr = NULL; + jboolean isCopy; + herr_t status = FAIL; + jbyte *propValBuf = NULL; - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk */ + UNUSED(clss); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk - * Signature: (JI[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk - (JNIEnv *env, jclass clss, jlong plist, jint max_ndims, jlongArray dims) -{ - herr_t status = -1; - jlong *theArray; - jboolean isCopy; - hsize_t *da; - int i; - - if (dims == NULL) { - h5nullArgument(env, "H5Pget_chunk: dims is NULL"); - } /* end if */ - else if (ENVPTR->GetArrayLength(ENVPAR dims) < max_ndims) { - h5badArgument(env, "H5Pget_chunk: dims array < max_ndims"); - } /* end else if */ - else { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_chunk: input dims not pinned"); - } /* end if */ - else { - da = (hsize_t *)HDmalloc((size_t)max_ndims * sizeof(hsize_t)); - if (da == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_chunk: dims not converted to hsize_t"); - } /* end if */ - else { - status = H5Pget_chunk((hid_t)plist, (int)max_ndims, da); - - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, JNI_ABORT); - HDfree (da); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < max_ndims; i++) { - theArray[i] = (jlong)da[i]; - } - HDfree (da); - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + copy_callback = prp_copy; + close_callback = prp_close; + compare_callback = prp_cmp; + set_callback = prp_set; + get_callback = prp_get; + delete_callback = prp_delete; - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pinsert2: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_alignment - * Signature: (JJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alignment - (JNIEnv *env, jclass clss, jlong plist, jlong threshold, jlong alignment) -{ - herr_t retVal = -1; - long thr = (long)threshold; - long align = (long)alignment; + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2: property value buffer not pinned"); - retVal = H5Pset_alignment((hid_t)plist, (hsize_t)thr, (hsize_t)align); - if (retVal < 0) - h5libraryError(env); + if ((status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, + (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, + (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1alignment */ +done: + if (propValBuf) + UNPIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, (status < 0) ? JNI_ABORT : 0); + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); +} /* end Java_hdf_hdf5lib_H5_H5Pinsert2 */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_alignment - * Signature: (J[J)I + * Method: H5Pinsert2_nocb + * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alignment - (JNIEnv *env, jclass clss, jlong plist, jlongArray alignment) +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb + (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) { - herr_t status = -1; - jlong *theArray; - jboolean isCopy; - hsize_t t; - hsize_t a; - - if (alignment == NULL) { - h5nullArgument(env, "H5Pget_alignment: input alignment is NULL"); - } /* end if */ - else { - if (ENVPTR->GetArrayLength(ENVPAR alignment) < 2) { - h5badArgument(env, "H5Pget_alignment: alignment input array < 2"); - } /* end if */ - else { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR alignment, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_alignment: input array not pinned"); - } /* end if */ - else { - status = H5Pget_alignment((hid_t)plist, &t, &a); - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jlong)t; - theArray[1] = (jlong)a; - ENVPTR->ReleaseLongArrayElements(ENVPAR alignment, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + const char *cstr = NULL; + jboolean isCopy; + herr_t status = FAIL; + jbyte *propValBuf = NULL; - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1alignment */ + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pinsert2_nocb: property name not pinned"); + + PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2_nocb: property value buffer not pinned"); + + if ((status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void *)propValBuf, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (propValBuf) + UNPIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, (status < 0) ? JNI_ABORT : 0); + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); +} /* end Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_external - * Signature: (JLjava/lang/String;JJ)I + * Method: H5Pset + * Signature: (JLjava/lang/String;I)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1external - (JNIEnv *env, jclass clss, jlong plist, jstring name, jlong offset, jlong size) +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pset + (JNIEnv *env, jclass clss, jlong plid, jstring name, jint val) { - herr_t status = -1; - const char *fileName; - off_t off; - hsize_t sz; - hid_t plid; + const char *cstr = NULL; + hid_t retVal = H5I_INVALID_HID; - plid = (hid_t)plist; - off = (off_t)offset; - sz = (hsize_t)size; + UNUSED(clss); - PIN_JAVA_STRING(name, fileName); - if (fileName != NULL) { - status = H5Pset_external(plid, fileName, off, sz); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pset: property name not pinned"); - UNPIN_JAVA_STRING(name, fileName); + if ((retVal = H5Pset((hid_t)plid, cstr, &val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); - } +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1external */ + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_external_count - * Signature: (J)I + * Method: H5Pexist + * Signature: (JLjava/lang/String;)Z */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external_1count - (JNIEnv *env, jclass clss, jlong plist) +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pexist + (JNIEnv *env, jclass clss, jlong plid, jstring name) { - int retVal = -1; + const char *cstr = NULL; + htri_t bval = JNI_FALSE; - retVal = H5Pget_external_count((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1external_1count */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pexist: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_external - * Signature: (JIJ[Ljava/lang/String;[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external - (JNIEnv *env, jclass clss, jlong plist, jint idx, jlong name_size, - jobjectArray name, jlongArray size) -{ - herr_t status = -1; - jlong *theArray; - jboolean isCopy; - char *file = NULL; - jstring str; - off_t o; - hsize_t s; - - if (name_size < 0) { - h5badArgument(env, "H5Pget_external: name_size < 0"); - } /* end if */ - else if ((size != NULL) && (ENVPTR->GetArrayLength(ENVPAR size) < 2)) { - h5badArgument(env, "H5Pget_external: size input array < 2"); - } /* end else if */ - else { - if (name_size > 0) { - file = (char *)HDmalloc(sizeof(char)*(size_t)name_size); - } /* end else */ - - status = H5Pget_external((hid_t) plist, (unsigned)idx, (size_t)name_size, - file, (off_t *)&o, (hsize_t *)&s); - if (status < 0) { - HDfree(file); - h5libraryError(env); - } /* end if */ - else { - if (size != NULL) { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError( env, "H5Pget_external: size array not pinned"); - } /* end if */ - else { - theArray[0] = o; - theArray[1] = (jlong)s; - ENVPTR->ReleaseLongArrayElements(ENVPAR size, theArray, 0); - } - } /* end if */ - - if (file != NULL) { - /* NewStringUTF may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR file); - if (str == NULL) { - HDfree(file); - h5JNIFatalError(env, "H5Pget_external: return array not created"); - } /* end if */ - else { - /* SetObjectArrayElement may raise exceptions */ - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); - HDfree(file); - } /* end else */ - } /* end if */ - } /* end else */ - } + if ((bval = H5Pexist((hid_t)plid, cstr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1external */ + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Pexist */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fill_value - * Signature: (JJ[B)I + * Method: H5Pget_size + * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1value - (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1size + (JNIEnv *env, jclass clss, jlong plid, jstring name) { - jint status = -1; - jbyte *byteP = NULL; - jboolean isCopy; - - if (value != NULL) { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Pget_fill_value: value array not pinned"); - } /* end if */ - else { - status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP); - - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - } - } /* end if */ - else { - status = H5Pset_fill_value((hid_t)plist_id, (hid_t)type_id, byteP); - } + const char *cstr = NULL; + size_t size = 0; + herr_t status = FAIL; - if (status < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1value */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pget_size: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fill_value - * Signature: (JJ[B)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1value - (JNIEnv *env, jclass clss, jlong plist_id, jlong type_id, jbyteArray value) -{ - jint status = -1; - jbyte *byteP; - jboolean isCopy; + if ((status = H5Pget_size((hid_t)plid, cstr, &size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (value == NULL) { - h5badArgument(env, "H5Pget_fill_value: value is NULL"); - } /* end if */ - else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Pget_fill_value: value array not pinned"); - } /* end if */ - else { - status = H5Pget_fill_value((hid_t)plist_id, (hid_t)type_id, byteP); - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); - } /* end else */ - } /* end else */ +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1value */ + return (jlong) size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1size */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_filter - * Signature: (JIIJ[I)I + * Method: H5Pget_nprops + * Signature: (J)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter, jint flags, - jlong cd_nelmts, jintArray cd_values) +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nprops + (JNIEnv *env, jclass clss, jlong plid) { - herr_t status = -1; - jint *theArray; - jboolean isCopy; - - if (cd_values == NULL) { - status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int)flags, (size_t)cd_nelmts, NULL); - if (status < 0) - h5libraryError(env); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pset_filter: input array not pinned"); - }/* end if */ - else { - status = H5Pset_filter((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int)flags, (size_t)cd_nelmts, (const unsigned int *)theArray); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, theArray, JNI_ABORT); - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + size_t nprops = 0; - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1filter */ + UNUSED(clss); + + if (H5Pget_nprops((hid_t)plid, &nprops) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)nprops; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nprops */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nfilters - * Signature: (J)I + * Method: H5Pget_class_name + * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nfilters - (JNIEnv *env, jclass clss, jlong plist) +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1class_1name + (JNIEnv *env, jclass clss, jlong plid) { - int retVal = -1; + char *c_str = NULL; + jstring j_str = NULL; - retVal = H5Pget_nfilters((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1nfilters */ + if (NULL == (c_str = H5Pget_class_name((hid_t)plid))) + H5_LIBRARY_ERROR(ENVONLY); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter - * Signature: (JI[I[J[IJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter_number, jintArray flags, - jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) -{ - herr_t status = -1; - jint *flagsArray; - jlong *cd_nelmtsArray; - jint *cd_valuesArray; - jint mode = JNI_ABORT; - jboolean isCopy; - jstring str; - char *filter; - - if (namelen <= 0) { - h5badArgument(env, "H5Pget_filter: namelen <= 0"); - } /* end if */ - else if (flags == NULL) { - h5badArgument(env, "H5Pget_filter: flags is NULL"); - } /* end else if */ - else if (cd_nelmts == NULL) { - h5badArgument(env, "H5Pget_filter: cd_nelmts is NULL"); - } /* end else if */ - else if (cd_values == NULL) { - h5badArgument(env, "H5Pget_filter: cd_values is NULL"); - } /* end else if */ - else { - filter = (char *)HDmalloc(sizeof(char)*(size_t)namelen); - if (filter == NULL) { - h5outOfMemory(env, "H5Pget_filter: namelen malloc failed"); - } /* end if */ - else { - flagsArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); - if (flagsArray == NULL) { - h5JNIFatalError(env, "H5Pget_filter: flags array not pinned"); - } /* end if */ - else { - cd_nelmtsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); - if (cd_nelmtsArray == NULL) { - h5JNIFatalError(env, "H5Pget_filter: nelmts array not pinned"); - } /* end if */ - else { - cd_valuesArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); - if (cd_valuesArray == NULL) { - h5JNIFatalError(env, "H5Pget_filter: elmts array not pinned"); - } /* end if */ - else { - /* direct cast (size_t *)variable fails on 32-bit environment */ - long long cd_nelmts_temp = *(cd_nelmtsArray); - size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - unsigned int filter_config; - status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, filter, &filter_config); - - *cd_nelmtsArray = (jlong)cd_nelmts_t; - /* end direct cast special */ - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - mode = 0; - - /* NewStringUTF may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR filter); - if (str == NULL) { - h5JNIFatalError(env, "H5Pget_filter: return string not pinned"); - } /* end if */ - else { - /* SetObjectArrayElement may throw exceptiosn */ - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); - } /* end else */ - } /* end else */ - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, mode); - } - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, mode); - } - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, mode); - } - HDfree(filter); - } - } /* end else */ + if (NULL == (j_str = ENVPTR->NewStringUTF(ENVONLY, c_str))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_class_name: out of memory - unable to construct string from UTF characters"); + } - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter */ +done: + if (c_str) + H5free_memory(c_str); + + return j_str; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1name */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_driver + * Method: H5Pget_class_parent * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1driver - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Pget_1class_1parent + (JNIEnv *env, jclass clss, jlong plid) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Pget_driver((hid_t) plist); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Pget_class_parent((hid_t)plid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1driver */ +} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1parent */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_cache - * Signature: (JIJJD)I + * Method: H5Pisa_class + * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1cache - (JNIEnv *env, jclass clss, jlong plist, jint mdc_nelmts, jlong rdcc_nelmts, - jlong rdcc_nbytes, jdouble rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pisa_1class + (JNIEnv *env, jclass clss, jlong plid, jlong pcls) { - herr_t retVal = -1; + htri_t retVal = FAIL; - retVal = H5Pset_cache((hid_t)plist, (int)mdc_nelmts, (size_t)rdcc_nelmts, - (size_t)rdcc_nbytes, (double) rdcc_w0); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1cache */ + if ((retVal = H5Pisa_class((hid_t)plid, (hid_t)pcls)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pisa_1class */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_cache - * Signature: (J[I[J[J[D)I + * Method: H5Pget + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1cache - (JNIEnv *env, jclass clss, jlong plist, jintArray mdc_nelmts, - jlongArray rdcc_nelmts, jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) +Java_hdf_hdf5lib_H5_H5Pget + (JNIEnv *env, jclass clss, jlong plid, jstring name) { - herr_t status = -1; - jint mode; - jdouble *w0Array = (jdouble *)NULL; - jlong *rdcc_nelmtsArray = (jlong *)NULL; - jlong *nbytesArray = (jlong *)NULL; - jboolean isCopy; - - if (rdcc_w0 != NULL) { - w0Array = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR rdcc_w0, &isCopy); - if (w0Array == NULL) { - h5JNIFatalError(env, "H5Pget_cache: w0_array array not pinned"); - return -1; - } /* end if */ - } /* end else */ - - if (rdcc_nelmts != NULL) { - rdcc_nelmtsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nelmts, &isCopy); - if (rdcc_nelmtsArray == NULL) { - /* exception -- out of memory */ - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); - } - h5JNIFatalError(env, "H5Pget_cache: rdcc_nelmts array not pinned"); - return -1; - } /* end if */ - } /* end else */ - - if (rdcc_nbytes != NULL) { - nbytesArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nbytes, &isCopy); - if (nbytesArray == NULL) { - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); - } /* end if */ - if (rdcc_nelmtsArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nelmts, rdcc_nelmtsArray, JNI_ABORT); - } /* end if */ - h5JNIFatalError(env, "H5Pget_cache: nbytesArray array not pinned"); - return -1; - } /* end if */ - } /* end else */ - - { /* direct cast (size_t *)variable fails on 32-bit environment */ - long long rdcc_nelmts_temp = *(rdcc_nelmtsArray); - size_t rdcc_nelmts_t = (size_t)rdcc_nelmts_temp; - long long nbytes_temp = *(nbytesArray); - size_t nbytes_t = (size_t)nbytes_temp; - - status = H5Pget_cache((hid_t)plist, (int *)NULL, &rdcc_nelmts_t, - &nbytes_t, (double *)w0Array); - - *rdcc_nelmtsArray = (jlong)rdcc_nelmts_t; - *nbytesArray = (jlong)nbytes_t; - } /* end direct cast special */ - - - if (status < 0) { - mode = JNI_ABORT; - } /* end if */ - else { - mode = 0; /* commit and free */ - } /* end else */ + const char *cstr = NULL; + jint val; + herr_t status = FAIL; - if (rdcc_nelmtsArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nelmts, rdcc_nelmtsArray, mode); - } /* end if */ + UNUSED(clss); - if (nbytesArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nbytes, nbytesArray, mode); - } /* end if */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pget: property name not pinned"); - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, mode); - } /* end if */ + if ((status = H5Pget((hid_t)plid, cstr, &val)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) { - h5libraryError(env); - } /* end if */ +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1cache */ + return (jint)val; +} /* end Java_hdf_hdf5lib_H5_H5Pget */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_buffer - * Signature: (JJ[B[B)I + * Method: H5Pequal + * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer - (JNIEnv *env, jclass clss, jlong plist, jlong size, jbyteArray tconv, jbyteArray bkg) +Java_hdf_hdf5lib_H5_H5Pequal + (JNIEnv *env, jclass clss, jlong plid1, jlong plid2) { - h5unimplemented(env, "H5Pset_buffer: not implemented"); - return -1; -#ifdef notdef - -/* DON'T IMPLEMENT THIS!!! */ - jint status = -1; - jbyte *tconvP; - jbyte *bkgP; - jboolean isCopy; - - if (tconv == NULL) - tconvP = (jbyte *)NULL; - else { - tconvP = ENVPTR->GetByteArrayElements(ENVPAR tconv, &isCopy); - if (tconvP == NULL) { - h5JNIFatalError(env, "H5Pset_buffer: tconv not pinned"); - return -1; - } - } - if (bkg == NULL) - bkgP = (jbyte *)NULL; - else { - bkgP = ENVPTR->GetByteArrayElements(ENVPAR bkg, &isCopy); - if (bkgP == NULL) { - h5JNIFatalError(env, "H5Pset_buffer: bkg not pinned"); - return -1; - } - } + htri_t retVal = FAIL; - status = H5Pset_buffer((hid_t)plist, (size_t)size, tconvP, bkgP); - if (status < 0) { - if (tconv != NULL) - ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, JNI_ABORT); - if (bkg != NULL) - ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, JNI_ABORT); - h5libraryError(env); - return -1; - } + UNUSED(clss); - if (tconv != NULL) - ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, 0); - if (bkg != NULL) - ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, 0); + if ((retVal = H5Pequal((hid_t)plid1, (hid_t)plid2)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)status; -#endif -} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer */ +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pequal */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_buffer - * Signature: (J[B[B)I + * Method: H5Piterate + * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer - (JNIEnv *env, jclass clss, jlong plist, jbyteArray tconv, jbyteArray bkg) +Java_hdf_hdf5lib_H5_H5Piterate + (JNIEnv *env, jclass clss, jlong prop_id, jintArray idx, jobject callback_op, jobject op_data) { - h5unimplemented(env, "H5Pget_buffer: not implemented"); - return -1; -#ifdef notdef - -/* DON'T IMPLEMENT THIS!!! */ - jlong status = -1; - jbyte *tconvP; - jbyte *bkgP; - jboolean isCopy; - - if (tconv == NULL) { - h5nullArgument(env, "H5Pget_buffer: tconv input array is NULL"); - return -1; - } - tconvP = ENVPTR->GetByteArrayElements(ENVPAR tconv, &isCopy); - if (tconvP == NULL) { - h5JNIFatalError(env, "H5Pget_buffer: tconv not pinned"); - return -1; - } - if (bkg == NULL) { - h5nullArgument(env, "H5Pget_buffer: bkg array is NULL"); - return -1; - } - bkgP = ENVPTR->GetByteArrayElements(ENVPAR bkg, &isCopy); - if (bkgP == NULL) { - h5JNIFatalError(env, "H5Pget_buffer: bkg not pinned"); - return -1; + cb_wrapper wrapper = { callback_op, op_data }; + jboolean isCopy; + jint *theArray = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + ENVPTR->GetJavaVM(ENVONLY, &jvm); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == op_data) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Piterate: op_data is NULL"); + if (NULL == callback_op) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Piterate: callback_op is NULL"); + + if (NULL == idx) { + if ((status = H5Piterate((hid_t)prop_id, NULL, (H5P_iterate_t)H5P_iterate_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); } + else { + PIN_INT_ARRAY(ENVONLY, idx, theArray, &isCopy, "H5Piterate: idx not pinned"); - status = H5Pget_buffer((hid_t)plist, tconvP, bkgP); - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, JNI_ABORT); - ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, JNI_ABORT); - h5libraryError(env); - return -1; + if ((status = H5Piterate((hid_t)prop_id, (int *)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void *)&wrapper)) < 0) + H5_LIBRARY_ERROR(ENVONLY); } - ENVPTR->ReleaseByteArrayElements(ENVPAR tconv, tconvP, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bkg, bkgP, 0); - return (jint)status; -#endif -} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer */ +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, idx, theArray, (status < 0) ? JNI_ABORT : 0); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_buffer_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) -{ - if (H5Pset_buffer((hid_t)plist, (size_t)size, NULL, NULL) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size */ + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Piterate */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_buffer_size - * Signature: (J)J + * Method: H5Pcopy_prop + * Signature: (JJLjava/lang/String;)I */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size - (JNIEnv *env, jclass clss, jlong plist) +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pcopy_1prop + (JNIEnv *env, jclass clss, jlong dst_plid, jlong src_plid, jstring name) { - size_t size = 0; + const char *cstr = NULL; + herr_t retVal = FAIL; - size = H5Pget_buffer((hid_t)plist, NULL, NULL); - if (size == 0) - h5libraryError(env); + UNUSED(clss); - return (jlong)size; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pcopy_prop: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_preserve - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1preserve - (JNIEnv *env, jclass clss, jlong plist, jboolean status) -{ - hbool_t st; - herr_t retVal = -1; - - if (status == JNI_TRUE) { - st = TRUE; - } /* end if */ - else if (status == JNI_FALSE) { - st = false; - } /* end else if */ - else { - h5badArgument(env, "H5Pset_preserve: status not TRUE or FALSE"); - return -1; - } /* end else */ + if ((retVal = H5Pcopy_prop((hid_t)dst_plid, (hid_t)src_plid, cstr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Pset_preserve((hid_t)plist, st); - if (retVal < 0) - h5libraryError(env); +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1preserve */ +} /* end Java_hdf_hdf5lib_H5_H5Pcopy_1prop */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_preserve - * Signature: (J)I + * Method: H5Premove + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1preserve - (JNIEnv *env, jclass clss, jlong plist) +Java_hdf_hdf5lib_H5_H5Premove + (JNIEnv *env, jclass clss, jlong plid, jstring name) { - herr_t retVal = -1; + const char *cstr = NULL; + herr_t retVal = FAIL; - retVal = H5Pget_preserve((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1preserve */ + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Premove: property name not pinned"); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_deflate - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1deflate - (JNIEnv *env, jclass clss, jlong plist, jint level) -{ - herr_t retVal = -1; + if ((retVal = H5Premove((hid_t)plid, cstr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Pset_deflate((hid_t)plist, (unsigned)level); - if (retVal < 0) - h5libraryError(env); +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1deflate */ +} /* end Java_hdf_hdf5lib_H5_H5Premove */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_gc_references - * Signature: (JZ)I + * Method: H5Punregister + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1gc_1references - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean gc_ref) +Java_hdf_hdf5lib_H5_H5Punregister + (JNIEnv *env, jclass clss, jlong plid, jstring name) { - herr_t retVal = -1; - unsigned gc_ref_val; + const char *cstr = NULL; + herr_t retVal = FAIL; - if (gc_ref == JNI_TRUE) - gc_ref_val = 1; - else - gc_ref_val = 0; + UNUSED(clss); - retVal = H5Pset_gc_references((hid_t)fapl_id, gc_ref_val); - if (retVal < 0) - h5libraryError(env); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Punregister: property name not pinned"); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1gc_1references */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_gc_references - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1gc_1references - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - unsigned gc_ref_val = 0; - jboolean bval = JNI_FALSE; + if ((retVal = H5Punregister((hid_t)plid, cstr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (H5Pget_gc_references((hid_t)fapl_id, (unsigned *)&gc_ref_val) < 0) { - h5libraryError(env); - } /* end if */ - else { - if (gc_ref_val == 1) - bval = JNI_TRUE; - } /* end else */ +done: + if (cstr) + UNPIN_JAVA_STRING(ENVONLY, name, cstr); - return bval; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1gc_1references */ + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Punregister */ /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_btree_ratios - * Signature: (JDDD)I + * Method: _H5Pclose_class + * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios - (JNIEnv *env, jclass clss, jlong plist_id, jdouble left, jdouble middle, jdouble right) +Java_hdf_hdf5lib_H5__1H5Pclose_1class + (JNIEnv *env, jclass clss, jlong plid) { - herr_t status = -1; + herr_t retVal = FAIL; - status = H5Pset_btree_ratios((hid_t)plist_id, (double)left,(double)middle, (double)right); - if (status < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios */ + if ((retVal = H5Pclose_class((hid_t)plid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_btree_ratios - * Signature: (J[D[D[D)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios - (JNIEnv *env, jclass clss, jlong plist_id, jdoubleArray left, - jdoubleArray middle, jdoubleArray right) +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pclose_1class */ + +static herr_t +H5P_cls_create_cb + (hid_t prop_id, void *create_data) { - herr_t status = -1; - jdouble *leftP; - jdouble *middleP; - jdouble *rightP; - jboolean isCopy; - - if (left == NULL) { - h5nullArgument(env, "H5Pget_btree_ratios: left input array is NULL"); - } /* end if */ - else if (middle == NULL) { - h5nullArgument(env, "H5Pget_btree_ratios: middle input array is NULL"); - } /* end else if */ - else if (right == NULL) { - h5nullArgument(env, "H5Pget_btree_ratios: right input array is NULL"); - } /* end else if */ - else { - leftP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR left, &isCopy); - if (leftP == NULL) { - h5JNIFatalError(env, "H5Pget_btree_ratios: left not pinned"); - } /* end if */ - else { - middleP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR middle, &isCopy); - if (middleP == NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_btree_ratios: middle not pinned"); - } /* end if */ - else { - rightP = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR right, &isCopy); - if (rightP == NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_btree_ratios: middle not pinned"); - } /* end if */ - else { - status = H5Pget_btree_ratios((hid_t)plist_id, (double *)leftP, - (double *)middleP, (double *)rightP); - if (status < 0) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, JNI_ABORT); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, JNI_ABORT); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR right, rightP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR left, leftP, 0); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR middle, middleP, 0); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR right, rightP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jmethodID mid; + JNIEnv *cbenv = NULL; + jclass cls; + jint status = -1; - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_cls_create_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_small_data_block_size - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) -{ - long sz = (long)size; - herr_t retVal = -1; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, create_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_small_data_block_size((hid_t)plist, (hsize_t)sz); - if (retVal < 0) - h5libraryError(env); + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_create_func_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size */ + status = CBENVPTR->CallIntMethod(CBENVONLY, create_callback, mid, prop_id, create_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_small_data_block_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size - (JNIEnv *env, jclass clss, jlong plist) +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); + + return (herr_t)status; +} /* end H5P_cls_create_cb */ + +static herr_t +H5P_cls_copy_cb + (hid_t new_prop_id, hid_t old_prop_id, void *copy_data) { - hsize_t s; + jmethodID mid; + JNIEnv *cbenv = NULL; + jclass cls; + jint status = -1; - if (H5Pget_small_data_block_size((hid_t)plist, &s) < 0) - h5libraryError(env); + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_cls_copy_cb: failed to attach current thread to JVM"); + } - return (jlong)s; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size */ + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, copy_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_alloc_time - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time - (JNIEnv *env, jclass clss, jlong plist, jint alloc_time) -{ - herr_t retVal = -1; + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JJLhdf/hdf5lib/callbacks/H5P_cls_copy_func_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_alloc_time((hid_t)plist, (H5D_alloc_time_t)alloc_time); - if (retVal < 0) - h5libraryError(env); + status = CBENVPTR->CallIntMethod(CBENVONLY, copy_callback, mid, new_prop_id, old_prop_id, copy_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time */ +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_alloc_time - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time - (JNIEnv *env, jclass clss, jlong plist, jintArray alloc_time) + return (herr_t)status; +} /* end H5P_cls_copy_cb */ + +static herr_t +H5P_cls_close_cb + (hid_t prop_id, void *close_data) { - herr_t retVal = -1; - jint *theArray; - jboolean isCopy; - H5D_alloc_time_t time; - - if (alloc_time == NULL) { - /* exception ? */ - h5nullArgument(env, "H5Pget_alloc_time: alloc_time is NULL"); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR alloc_time, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_alloc_time: alloc_time not pinned"); - } /* end if */ - else { - retVal = H5Pget_alloc_time((hid_t)plist, &time); - if (retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR alloc_time, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = time; - ENVPTR->ReleaseIntArrayElements(ENVPAR alloc_time, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ + jmethodID mid; + JNIEnv *cbenv = NULL; + jclass cls; + jint status = -1; - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_cls_close_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fill_time - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1time - (JNIEnv *env, jclass clss, jlong plist, jint fill_time) -{ - herr_t retVal = -1; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, close_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_fill_time((hid_t)plist, (H5D_fill_time_t)fill_time); - if (retVal < 0) - h5libraryError(env); + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_close_func_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fill_1time */ + status = CBENVPTR->CallIntMethod(CBENVONLY, close_callback, mid, prop_id, close_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fill_time - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1time - (JNIEnv *env, jclass clss, jlong plist, jintArray fill_time) -{ - herr_t retVal = -1; - jint *theArray; - jboolean isCopy; - H5D_fill_time_t time; - - if (fill_time == NULL) { - /* exception ? */ - h5nullArgument(env, "H5Pget_fill_time: fill_time is NULL"); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR fill_time, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_fill_time: fill_time not pinned"); - } /* end if */ - else { - retVal = H5Pget_fill_time((hid_t)plist, &time); - if (retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR fill_time, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jint)time; - ENVPTR->ReleaseIntArrayElements(ENVPAR fill_time, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fill_1time */ + return (herr_t)status; +} /* end H5P_cls_close_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pfill_value_defined - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined - (JNIEnv *env, jclass clss, jlong plist, jintArray status) +static herr_t +H5P_prp_create_cb + (const char *name, size_t size, void *value) { - herr_t retVal = -1; - jint *theArray; - jboolean isCopy; - H5D_fill_value_t value; - - if (status == NULL) { - /* exception ? */ - h5nullArgument(env, "H5Pfill_value_defined: status is NULL"); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR status, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pfill_value_defined: status not pinned"); - } /* end if */ - else { - retVal = H5Pfill_value_defined((hid_t)plist, &value); - if (retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR status, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = value; - ENVPTR->ReleaseIntArrayElements(ENVPAR status, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ + jmethodID mid; + jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_create_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fletcher32 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 - (JNIEnv *env, jclass clss, jlong plist) -{ - herr_t retVal = -1; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, create_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_fletcher32((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(Ljava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 */ + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_edc_check - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1edc_1check - (JNIEnv *env, jclass clss, jlong plist, jint check) -{ - herr_t retVal = -1; + status = CBENVPTR->CallIntMethod(CBENVONLY, create_callback, mid, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_edc_check((hid_t)plist, (H5Z_EDC_t)check); - if (retVal < 0) - h5libraryError(env); +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1edc_1check */ + return (herr_t)status; +} /* end H5P_prp_create_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_edc_check - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1edc_1check - (JNIEnv *env, jclass clss, jlong plist) +static herr_t +H5P_prp_set_cb + (hid_t prop_id, const char *name, size_t size, void *value) { - H5Z_EDC_t retVal = -1; - - retVal = H5Pget_edc_check((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + jmethodID mid; + jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1edc_1check */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_set_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shuffle - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shuffle - (JNIEnv *env, jclass clss, jlong plist) -{ - herr_t retVal = -1; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, set_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_shuffle((hid_t)plist); - if (retVal < 0) - h5libraryError(env); + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1shuffle */ + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_szip - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1szip - (JNIEnv *env, jclass clss, jlong plist, jint options_mask, jint pixels_per_block) -{ - herr_t retVal = -1; + status = CBENVPTR->CallIntMethod(CBENVONLY, set_callback, mid, prop_id, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_szip((hid_t)plist, (unsigned int)options_mask, (unsigned int)pixels_per_block); - if (retVal < 0) - h5libraryError(env); +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1szip */ + return (herr_t)status; +} /* end H5P_prp_set_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_hyper_vector_size - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size - (JNIEnv *env, jclass clss, jlong plist, jlong vector_size) +static herr_t +H5P_prp_get_cb + (hid_t prop_id, const char *name, size_t size, void *value) { - herr_t retVal = -1; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - retVal = H5Pset_hyper_vector_size((hid_t)plist, (size_t)vector_size); - if (retVal < 0) - h5libraryError(env); + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_get_cb: failed to attach current thread to JVM"); + } - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size */ + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, get_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_hyper_vector_size - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size - (JNIEnv *env, jclass clss, jlong plist, jlongArray vector_size) -{ - herr_t retVal = -1; - jlong *theArray; - size_t size; - jboolean isCopy; - - if (vector_size == NULL) { - /* exception ? */ - h5nullArgument(env, "H5Pget_hyper_vector_size: vector_size is NULL"); - } /* end if */ - else { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR vector_size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_hyper_vector_size: vector_size not pinned"); - } /* end if */ - else { - retVal = H5Pget_hyper_vector_size((hid_t)plist, &size); - if (retVal < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR vector_size, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jlong)size; - ENVPTR->ReleaseLongArrayElements(ENVPAR vector_size, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size */ + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pall_filters_avail - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail - (JNIEnv *env, jclass clss, jlong dcpl_id) -{ - htri_t bval = JNI_FALSE; - - bval = H5Pall_filters_avail((hid_t)dcpl_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - - return (jboolean)bval; -} /* end Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pmodify_filter - * Signature: (JIIJ[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pmodify_1filter - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jint flags, jlong cd_nelmts, jintArray cd_values) -{ - herr_t status = -1; - jint *cd_valuesP; - jboolean isCopy; - - if (cd_values == NULL) { - h5nullArgument(env, "H5Pmodify_filter: cd_values is NULL"); - } /* end if */ - else { - cd_valuesP = ENVPTR->GetIntArrayElements(ENVPAR cd_values,&isCopy); - if (cd_valuesP == NULL) { - h5JNIFatalError(env, "H5Pmodify_filter: cd_values not pinned"); - } /* end if */ - else { - status = H5Pmodify_filter((hid_t)plist, (H5Z_filter_t)filter,(const unsigned int)flags, - (size_t)cd_nelmts, (unsigned int *)cd_valuesP); - - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesP, JNI_ABORT); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pmodify_1filter */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter_by_id - * Signature: (JI[I[J[IJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name) -{ - jboolean isCopy; - herr_t status = -1; - jint *cd_valuesArray; - jint *flagsArray; - jlong *cd_nelmtsArray; - jstring str; - char *aName; - int i = 0; - int rank; - long bs; - - bs = (long)namelen; - if (bs <= 0) { - h5badArgument(env, "H5Pget_filter_by_id: namelen <= 0"); - } /* end if */ - else if (flags == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: flags is NULL"); - } /* end else if */ - else if (cd_nelmts == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: cd_nelms is NULL"); - } /* end else if */ - else if (cd_values == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: cd_values is NULL"); - } /* end else if */ - else if (name == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: name is NULL"); - } /* end else if */ - else { - aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); - if (aName == NULL) { - h5outOfMemory(env, "H5Pget_filter_by_id: malloc failed"); - return -1; - } /* end if */ - - flagsArray = ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); - if (flagsArray == NULL) { - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); - return -1; - } /* end if */ - - cd_nelmtsArray = ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); - if (cd_nelmtsArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: cd_nelms not pinned"); - return -1; - } /* end if */ - - cd_valuesArray = ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); - rank = ENVPTR->GetArrayLength(ENVPAR cd_values); - if (cd_valuesArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: cd_values array not converted to unsigned int."); - return -1; - } /* end if */ - - { /* direct cast (size_t *)variable fails on 32-bit environment */ - long long cd_nelmts_temp = *(cd_nelmtsArray); - size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - unsigned int filter_config; - - status = H5Pget_filter_by_id2( (hid_t)plist, (H5Z_filter_t)filter, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, (char *)aName, &filter_config); - - *cd_nelmtsArray = (jlong)cd_nelmts_t; - } /* end direct cast special */ - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); - HDfree(aName); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); - - HDfree(aName); - } /* end else */ - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fclose_degree - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree - (JNIEnv *env, jclass clss, jlong plist, jint fc_degree) -{ - herr_t retVal = -1; - - retVal = H5Pset_fclose_degree((hid_t)plist, (H5F_close_degree_t)fc_degree); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fclose_degree - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree - (JNIEnv *env, jclass clss, jlong plist) -{ - H5F_close_degree_t degree; - - if (H5Pget_fclose_degree((hid_t)plist, °ree) < 0) - h5libraryError(env); - - return (jint)degree; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree */ - - -/********************************************************************** - * * - * File access properties * - * * - **********************************************************************/ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_family - * Signature: (JJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family - (JNIEnv *env, jclass clss, jlong plist, jlong memb_size, jlong memb_plist) -{ - long ms = (long)memb_size; - herr_t retVal = -1; - - retVal = H5Pset_fapl_family((hid_t)plist, (hsize_t)ms, (hid_t)memb_plist); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_family - * Signature: (J[J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family - (JNIEnv *env, jclass clss, jlong tid, jlongArray memb_size, jlongArray memb_plist) -{ - herr_t status = -1; - jlong *sizeArray; - jlong *plistArray; - jint mode = JNI_ABORT; - jboolean isCopy; - hsize_t *sa; - size_t i; - size_t rank; - - if (memb_size == NULL) { - h5nullArgument(env, "H5Pget_family: memb_size is NULL"); - } /* end if */ - else if (memb_plist == NULL) { - h5nullArgument(env, "H5Pget_family: memb_plist is NULL"); - } /* end else if */ - else { - sizeArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_size, &isCopy); - if (sizeArray == NULL) { - h5JNIFatalError(env, "H5Pget_family: sizeArray not pinned"); - } /* end if */ - else { - rank = (size_t)ENVPTR->GetArrayLength(ENVPAR memb_size); - sa = (hsize_t *)HDmalloc(rank * sizeof(hsize_t)); - if (sa == NULL) { - h5JNIFatalError(env, "H5Screate-simple: dims not converted to hsize_t"); - } /* end if */ - else { - plistArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_plist, &isCopy); - if (plistArray == NULL) { - h5JNIFatalError(env, "H5Pget_family: plistArray not pinned"); - } /* end if */ - else { - status = H5Pget_fapl_family ((hid_t)tid, sa, (hid_t *)plistArray); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < rank; i++) { - sizeArray[i] = (jlong)sa[i]; - } /* end for */ - mode = 0; - } /* end else */ - ENVPTR->ReleaseLongArrayElements(ENVPAR memb_plist, plistArray, mode); - } - HDfree(sa); - } - ENVPTR->ReleaseLongArrayElements(ENVPAR memb_size, sizeArray, mode); - } - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_core - * Signature: (JJZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core - (JNIEnv *env, jclass clss, jlong fapl_id, jlong increment, jboolean backing_store) -{ - herr_t retVal = -1; - - retVal = H5Pset_fapl_core((hid_t)fapl_id, (size_t)increment, (hbool_t)backing_store); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_core - * Signature: (J[J[Z)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core - (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray increment, jbooleanArray backing_store) -{ - herr_t status = -1; - jint mode = JNI_ABORT; - jlong *incArray; - jboolean *backArray; - jboolean isCopy; - - if (increment == NULL) { - h5nullArgument(env, "H5Pget_fapl_core: increment is NULL"); - } /* end if */ - else if (backing_store == NULL) { - h5nullArgument(env, "H5Pget_fapl_core: backing_store is NULL"); - } /* end else if */ - else { - incArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR increment, &isCopy); - if (incArray == NULL) { - h5JNIFatalError(env, "H5Pget_fapl_core: incArray not pinned"); - } /* end if */ - else { - backArray = (jboolean *)ENVPTR->GetBooleanArrayElements(ENVPAR backing_store, &isCopy); - if (backArray == NULL) { - h5JNIFatalError(env, "H5Pget_fapl_core: backArray not pinned"); - } /* end if */ - else { - /* direct cast (size_t *)variable fails on 32-bit environment */ - long long inc_temp = *(incArray); - size_t inc_t = (size_t)inc_temp; - - status = H5Pget_fapl_core((hid_t)fapl_id, &inc_t, (hbool_t *)backArray); - - *incArray = (jlong)inc_t; - /* end direct cast special */ - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - mode = 0; - } /* end else */ - ENVPTR->ReleaseBooleanArrayElements(ENVPAR backing_store, backArray, mode); - } - ENVPTR->ReleaseLongArrayElements(ENVPAR increment, incArray, mode); - } - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_family_offset - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1family_1offset - (JNIEnv *env, jclass clss, jlong fapl_id, jlong offset) -{ - herr_t retVal = -1; - - retVal = H5Pset_family_offset ((hid_t)fapl_id, (hsize_t)offset); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1family_1offset */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_family_offset - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1family_1offset - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - hsize_t offset = 0; - herr_t retVal = -1; - - retVal = H5Pget_family_offset ((hid_t)fapl_id, &offset); - if (retVal < 0) - h5libraryError(env); - - return (jlong)offset; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1family_1offset */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_log - * Signature: (JLjava/lang/String;JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log - (JNIEnv *env, jclass clss, jlong fapl_id, jstring logfile, jlong flags, jlong buf_size) -{ - herr_t retVal = -1; - const char *pLogfile; - - PIN_JAVA_STRING(logfile, pLogfile); - if (pLogfile != NULL) { - retVal = H5Pset_fapl_log( (hid_t)fapl_id, pLogfile, (unsigned long long)flags, (size_t)buf_size ); - - UNPIN_JAVA_STRING(logfile, pLogfile); - - if (retVal < 0) - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Premove_filter - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5P1remove_1filter - (JNIEnv *env, jclass clss, jlong obj_id, jint filter) -{ - herr_t status = -1; - - status = H5Premove_filter ((hid_t)obj_id, (H5Z_filter_t)filter); - if (status < 0) - h5libraryError(env); - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5P1remove_1filter */ - - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset - * Signature: (JLjava/lang/String;I)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pset - (JNIEnv *env, jclass clss, jlong plid, jstring name, jint val) -{ - hid_t retVal = -1; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Pset((hid_t)plid, cstr, &val); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jlong)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pexist - * Signature: (JLjava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pexist - (JNIEnv *env, jclass clss, jlong plid, jstring name) -{ - htri_t bval = JNI_FALSE; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - bval = H5Pexist((hid_t)plid, cstr); - - UNPIN_JAVA_STRING(name, cstr); - - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } - - return (jboolean)bval; -} /* end Java_hdf_hdf5lib_H5_H5Pexist */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_size - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1size - (JNIEnv *env, jclass clss, jlong plid, jstring name) -{ - hid_t retVal = -1; - const char *cstr; - size_t size = 0; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Pget_size((hid_t)plid, cstr, &size); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jlong) size; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nprops - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nprops - (JNIEnv *env, jclass clss, jlong plid) -{ - size_t nprops; - - if (H5Pget_nprops((hid_t)plid, &nprops) < 0) - h5libraryError(env); - - return (jlong)nprops; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1nprops */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_class_name - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1name - (JNIEnv *env, jclass clss, jlong plid) -{ - char *c_str; - jstring j_str = NULL; - - c_str = H5Pget_class_name((hid_t)plid); - if (c_str == NULL) { - h5libraryError(env); - } /* end if */ - else { - j_str = ENVPTR->NewStringUTF(ENVPAR c_str); - H5free_memory(c_str); - - if (j_str == NULL) - h5JNIFatalError(env,"H5Pget_class_name: return string failed"); - } /* end else */ - return j_str; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1name */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_class_parent - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1parent - (JNIEnv *env, jclass clss, jlong plid) -{ - hid_t retVal = -1; - - retVal = H5Pget_class_parent((hid_t)plid); - if (retVal < 0) - h5libraryError(env); - - return (jlong)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1class_1parent */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pisa_class - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pisa_1class - (JNIEnv *env, jclass clss, jlong plid, jlong pcls) -{ - htri_t retVal = -1; - - retVal = H5Pisa_class((hid_t)plid, (hid_t)pcls); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pisa_1class */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget - (JNIEnv *env, jclass clss, jlong plid, jstring name) -{ - herr_t retVal = -1; - const char *cstr; - jint val; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Pget((hid_t)plid, cstr, &val); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jint)val; -} /* end Java_hdf_hdf5lib_H5_H5Pget */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pequal - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pequal - (JNIEnv *env, jclass clss, jlong plid1, jlong plid2) -{ - htri_t retVal = -1; - - retVal = H5Pequal((hid_t)plid1, (hid_t)plid2); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pequal */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pcopy_prop - * Signature: (JJLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pcopy_1prop - (JNIEnv *env, jclass clss, jlong dst_plid, jlong src_plid, jstring name) -{ - herr_t retVal = -1; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Pcopy_prop((hid_t)dst_plid, (hid_t)src_plid, cstr); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pcopy_1prop */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Premove - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Premove - (JNIEnv *env, jclass clss, jlong plid, jstring name) -{ - herr_t retVal = -1; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Premove((hid_t)plid, cstr); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Premove */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Punregister - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Punregister - (JNIEnv *env, jclass clss, jlong plid, jstring name) -{ - herr_t retVal = -1; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - retVal = H5Punregister((hid_t)plid, cstr); - - UNPIN_JAVA_STRING(name, cstr); - - if (retVal < 0) - h5libraryError(env); - } - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Punregister */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pclose_class - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose_1class - (JNIEnv *env, jclass clss, jlong plid) -{ - herr_t retVal = -1; - - retVal = H5Pclose_class((hid_t)plid); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5__1H5Pclose_1class */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter2 - * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter2 - (JNIEnv *env, jclass clss, jlong plist, jint filter_number, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, - jobjectArray name, jintArray filter_config) -{ - herr_t status = -1; - jint *flagsArray; - jlong *cd_nelmtsArray; - jint *cd_valuesArray; - jint *filter_configArray; - jboolean isCopy; - char *filter; - jstring str; - - if (namelen <= 0) { - h5badArgument(env, "H5Pget_filter: namelen <= 0"); - } /* end if */ - else if (flags == NULL) { - h5badArgument(env, "H5Pget_filter: flags is NULL"); - } /* end else if */ - else if (cd_nelmts == NULL) { - h5badArgument(env, "H5Pget_filter: cd_nelmts is NULL"); - } /* end else if */ - else if (filter_config == NULL) { - h5badArgument(env, "H5Pget_filter: filter_config is NULL"); - } /* end else if */ - else { - filter = (char*)HDmalloc(sizeof(char)*(size_t)namelen); - if (filter == NULL) { - h5outOfMemory(env, "H5Pget_filter: namelent malloc failed"); - return -1; - } /* end if */ - flagsArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR flags, &isCopy); - if (flagsArray == NULL) { - HDfree(filter); - h5JNIFatalError(env, "H5Pget_filter: flags array not pinned"); - return -1; - } /* end if */ - - cd_nelmtsArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); - if (cd_nelmtsArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(filter); - h5JNIFatalError(env, "H5Pget_filter: nelmts array not pinned"); - return -1; - } /* end if */ - filter_configArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR filter_config, &isCopy); - if (filter_configArray == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(filter); - h5JNIFatalError(env, "H5Pget_filter: filter_config array not pinned"); - return -1; - } /* end if */ - - if (*cd_nelmtsArray == 0 && cd_values == NULL) { - /* direct cast (size_t *)variable fails on 32-bit environment */ - long long cd_nelmts_temp = 0; - size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - - status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, NULL, - (size_t)namelen, filter, (unsigned int *)filter_configArray); - - *cd_nelmtsArray = (jlong)cd_nelmts_t; - } /* end if */ - else { - if (cd_values == NULL) { - h5badArgument(env, "H5Pget_filter: cd_values is NULL"); - return -1; - } /* end if */ - cd_valuesArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); - if (cd_valuesArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(filter); - h5JNIFatalError(env, "H5Pget_filter: elmts array not pinned"); - return -1; - } /* end if */ - - { /* direct cast (size_t *)variable fails on 32-bit environment */ - long long cd_nelmts_temp = *(cd_nelmtsArray); - size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - - status = H5Pget_filter2((hid_t)plist, (unsigned)filter_number, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, filter, (unsigned int *)filter_configArray); - - *cd_nelmtsArray = (jlong)cd_nelmts_t; - } /* end direct cast special */ - } /* end else */ - - if (status < 0) { - if (cd_values) - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(filter); - h5libraryError(env); - } /* end if */ - else { - if (cd_values) - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); - /* NewStringUTF may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR filter); - HDfree(filter); - if (str == NULL) - h5JNIFatalError(env, "H5Pget_filter: return string not pinned"); - else - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); - } /* end else */ - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter2 */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter_by_id2 - * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 - (JNIEnv *env, jclass clss, jlong plist, jint filter, - jintArray flags, jlongArray cd_nelmts, jintArray cd_values, jlong namelen, jobjectArray name, jintArray filter_config) -{ - herr_t status = -1; - int i = 0; - jint *cd_valuesArray; - jint *flagsArray; - jint *filter_configArray; - jlong *cd_nelmtsArray; - jboolean isCopy; - long bs; - char *aName; - jstring str; - - bs = (long)namelen; - if (bs <= 0) { - h5badArgument(env, "H5Pget_filter_by_id: namelen <= 0"); - } /* end if */ - else if (flags == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: flags is NULL"); - } /* end else if */ - else if (cd_nelmts == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: cd_nelms is NULL"); - } /* end else if */ - else if (cd_values == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: cd_values is NULL"); - } /* end else if */ - else if (name == NULL) { - h5nullArgument(env, "H5Pget_filter_by_id: name is NULL"); - } /* end else if */ - else if (filter_config == NULL) { - h5badArgument(env, "H5Pget_filter_by_id: filter_config is NULL"); - } /* end else if */ - else { - aName = (char*)HDmalloc(sizeof(char) * (size_t)bs); - if (aName == NULL) { - h5outOfMemory(env, "H5Pget_filter_by_id: malloc failed"); - return -1; - } /* end if */ - flagsArray = ENVPTR->GetIntArrayElements(ENVPAR flags,&isCopy); - if (flagsArray == NULL) { - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); - return -1; - } /* end if */ - cd_nelmtsArray = ENVPTR->GetLongArrayElements(ENVPAR cd_nelmts, &isCopy); - if (cd_nelmtsArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: cd_nelms not pinned"); - return -1; - } /* end if */ - cd_valuesArray = ENVPTR->GetIntArrayElements(ENVPAR cd_values, &isCopy); - if (cd_valuesArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: cd_values array not converted to unsigned int."); - return -1; - } /* end if */ - filter_configArray = ENVPTR->GetIntArrayElements(ENVPAR filter_config, &isCopy); - if (filter_configArray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); - HDfree(aName); - h5JNIFatalError(env, "H5Pget_filter_by_id: flags not pinned"); - return -1; - } /* end if */ - - { /* direct cast (size_t *)variable fails on 32-bit environment */ - long long cd_nelmts_temp = *(cd_nelmtsArray); - size_t cd_nelmts_t = (size_t)cd_nelmts_temp; - - status = H5Pget_filter_by_id2((hid_t)plist, (H5Z_filter_t)filter, - (unsigned int *)flagsArray, &cd_nelmts_t, (unsigned int *)cd_valuesArray, - (size_t)namelen, (char *)aName, (unsigned int *)filter_configArray); - - *cd_nelmtsArray = (jlong)cd_nelmts_t; - } /* end direct cast special handling */ - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, JNI_ABORT); - HDfree(aName); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - HDfree(aName); - ENVPTR->ReleaseIntArrayElements(ENVPAR flags, flagsArray, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR cd_nelmts, cd_nelmtsArray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesArray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR filter_config, filter_configArray, 0); - } /* end else */ - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nlinks - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nlinks - (JNIEnv *env, jclass clss, jlong lapl_id) -{ - size_t nlinks; - if (H5Pget_nlinks((hid_t)lapl_id, &nlinks) < 0) - h5libraryError(env); - - return (jlong) nlinks; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1nlinks */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_nlinks - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nlinks - (JNIEnv *env, jclass clss, jlong lapl_id, jlong nlinks) -{ - herr_t retVal = -1; - - if (nlinks <= 0) { - h5badArgument(env, "H5Pset_1nlinks: nlinks_l <= 0"); - } /* end if */ - else { - retVal = H5Pset_nlinks((hid_t)lapl_id, (size_t)nlinks); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1nlinks */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_libver_bounds - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds - (JNIEnv *env, jclass clss, jlong fapl_id, jintArray libver) -{ - herr_t retVal = -1; - H5F_libver_t *theArray = NULL; - jboolean isCopy; - - if (libver == NULL) { - h5nullArgument(env, "H5Pget_libver_bounds: libversion bounds is NULL"); - } /* end if */ - else { - theArray = (H5F_libver_t*)ENVPTR->GetIntArrayElements(ENVPAR libver, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_libver_bounds: input not pinned"); - } /* end if */ - else { - retVal = H5Pget_libver_bounds((hid_t)fapl_id, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR libver, (jint*)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR libver, (jint*)theArray, 0); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_libver_bounds - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds - (JNIEnv *env, jclass clss, jlong fapl_id, jint low, jint high) -{ - herr_t retVal = -1; - - retVal = H5Pset_libver_bounds((hid_t)fapl_id, (H5F_libver_t)low, (H5F_libver_t)high); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_link_creation_order - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order - (JNIEnv *env, jclass clss, jlong gcpl_id) -{ - unsigned crt_order_flags; - - if(H5Pget_link_creation_order((hid_t)gcpl_id, &crt_order_flags) < 0) - h5libraryError(env); - - return (jint)crt_order_flags; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_link_creation_order - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order - (JNIEnv *env, jclass clss, jlong gcpl_id, jint crt_order_flags) -{ - herr_t retVal = -1; - - retVal = H5Pset_link_creation_order((hid_t)gcpl_id, (unsigned)crt_order_flags); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_attr_creation_order - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order - (JNIEnv *env, jclass clss, jlong ocpl_id) -{ - unsigned crt_order_flags; - - if(H5Pget_attr_creation_order((hid_t)ocpl_id, &crt_order_flags) < 0) - h5libraryError(env); - - return (jint)crt_order_flags; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_attr_creation_order - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order - (JNIEnv *env, jclass clss, jlong ocpl_id, jint crt_order_flags) -{ - herr_t retVal = -1; - - retVal = H5Pset_attr_creation_order((hid_t)ocpl_id, (unsigned)crt_order_flags); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_copy_object - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1copy_1object - (JNIEnv *env, jclass clss, jlong ocp_plist_id, jint copy_options) -{ - herr_t retVal = -1; - - retVal = H5Pset_copy_object((hid_t)ocp_plist_id, (unsigned)copy_options); - if(retVal < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1copy_1object */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_copy_object - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1copy_1object - (JNIEnv *env, jclass clss, jlong ocp_plist_id) -{ - unsigned copy_options; - - if(H5Pget_copy_object((hid_t)ocp_plist_id, ©_options) < 0) - h5libraryError(env); - - return (jint)copy_options; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1copy_1object */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_create_intermediate_group - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group - (JNIEnv *env, jclass clss, jlong lcpl_id, jboolean crt_intermed_group) -{ - herr_t retVal = -1; - - retVal = H5Pset_create_intermediate_group((hid_t)lcpl_id, (unsigned)crt_intermed_group); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_create_intermediate_group - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group - (JNIEnv *env, jclass clss, jlong lcpl_id) -{ - unsigned crt_intermed_group; - - if(H5Pget_create_intermediate_group((hid_t)lcpl_id, &crt_intermed_group) < 0) - h5libraryError(env); - - return (jboolean)crt_intermed_group; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_data_transform - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1data_1transform - (JNIEnv *env, jclass clss, jlong plist_id, jstring expression) -{ - herr_t retVal = -1; - const char *express; - - PIN_JAVA_STRING(expression, express); - if (express != NULL) { - retVal = H5Pset_data_transform((hid_t)plist_id, express); - - UNPIN_JAVA_STRING(expression, express); - - if (retVal < 0) - h5libraryError(env); - } - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1data_1transform */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_data_transform - * Signature: (J[Ljava/lang/String;J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1data_1transform - (JNIEnv *env, jclass clss, jlong plist_id, jobjectArray expression, jlong size) -{ - size_t buf_size; - char *express; - jlong express_size = -1; - jstring str = NULL; - - if (size <= 0) { - h5badArgument(env, "H5Pget_data_transform: size <= 0"); - } /* end if */ - else { - express_size = (jlong)H5Pget_data_transform((hid_t)plist_id, (char*)NULL, (size_t)size); - if(express_size < 0) { - h5libraryError(env); - } /* end if */ - else { - buf_size = (size_t)express_size + 1;/* add extra space for the null terminator */ - express = (char*)HDmalloc(sizeof(char) * buf_size); - if (express == NULL) { - h5outOfMemory(env, "H5Pget_data_transform: malloc failed "); - } /* end if */ - else { - express_size = (jlong)H5Pget_data_transform((hid_t)plist_id, express, (size_t)size); - if (express_size < 0) { - HDfree(express); - h5libraryError(env); - } - else { - str = ENVPTR->NewStringUTF(ENVPAR express); - HDfree(express); - if (str == NULL) - h5JNIFatalError(env, "H5Pget_data_transform: return string not created"); - else - ENVPTR->SetObjectArrayElement(ENVPAR expression, 0, str); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - return express_size; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1data_1transform */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_acc_flags - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags - (JNIEnv *env, jclass clss, jlong lapl_id) -{ - unsigned flags; - - if(H5Pget_elink_acc_flags((hid_t)lapl_id, &flags) < 0) - h5libraryError(env); - - return (jint)flags; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_acc_flags - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags - (JNIEnv *env, jclass clss, jlong lapl_id, jint flags) -{ - herr_t retVal = -1; - - retVal = H5Pset_elink_acc_flags((hid_t)lapl_id, (unsigned)flags); - if (retVal < 0) - h5libraryError(env); - - return (jint) retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_link_phase_change - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change - (JNIEnv *env, jclass clss, jlong gcpl_id, jint max_compact, jint min_dense) -{ - herr_t retVal = -1; - - if(max_compact < min_dense) { - h5badArgument(env, "H5Pset_link_phase_change: max compact value must be >= min dense value"); - } /* end if */ - else if(max_compact > 65535) { - h5badArgument(env, "H5Pset_link_phase_change: max compact value must be < 65536"); - } /* end else if */ - else if(min_dense > 65535) { - h5badArgument(env, "H5Pset_link_phase_change: min dense value must be < 65536"); - } /* end else if */ - else { - retVal = H5Pset_link_phase_change((hid_t)gcpl_id, (unsigned)max_compact, (unsigned)min_dense); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_link_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change - (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray links) -{ - herr_t retVal = -1; - unsigned *theArray = NULL; - jboolean isCopy; - - if (links == NULL) { - h5nullArgument( env, "H5Pget_link_phase_change: links is NULL"); - } /* end if */ - else { - theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR links, &isCopy); - if (theArray == NULL) { - h5JNIFatalError( env, "H5Pget_link_phase_change: input not pinned"); - } /* end if */ - else { - retVal = H5Pget_link_phase_change((hid_t)gcpl_id, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR links, (jint *)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR links, (jint *)theArray, 0); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_attr_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change - (JNIEnv *env, jclass clss, jlong ocpl_id, jintArray attributes) -{ - herr_t retVal = -1; - unsigned *theArray = NULL; - jboolean isCopy; - - if (attributes == NULL) { - h5nullArgument(env, "H5Pget_attr_phase_change: attributes is NULL"); - } /* end if */ - else { - theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR attributes, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_attr_phase_change: input not pinned"); - } /* end if */ - else { - retVal = H5Pget_attr_phase_change((hid_t)ocpl_id, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR attributes, (jint *)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR attributes, (jint *)theArray, 0); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_attr_phase_change - * Signature: (JII)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change - (JNIEnv *env, jclass clss, jlong ocpl_id, jint max_compact, jint min_dense) -{ - herr_t retVal = -1; - - retVal = H5Pset_attr_phase_change((hid_t)ocpl_id, (unsigned)max_compact, (unsigned)min_dense); - if(retVal < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change - (JNIEnv *env, jclass clss, jlong fcpl_id, jintArray size) -{ - herr_t retVal = -1; - unsigned *theArray = NULL; - jboolean isCopy; - - if (size == NULL) { - h5nullArgument(env, "H5Pget_shared_mesg_phase_change: size is NULL"); - } /* end if */ - else { - theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR size, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_shared_mesg_phase_change: input not pinned"); - } /* end if */ - else { - retVal = H5Pget_shared_mesg_phase_change((hid_t)fcpl_id, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR size, (jint *)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR size, (jint *)theArray, 0); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_phase_change - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change - (JNIEnv *env, jclass clss, jlong fcpl_id, jint max_list, jint min_btree) -{ - herr_t retVal = -1; - - /* Check that values are sensible. The min_btree value must be no greater - * than the max list plus one. - * - * Range check to make certain they will fit into encoded form. - */ - - if(max_list + 1 < min_btree) { - h5badArgument(env, "H5Pset_shared_mesg_phase_change: minimum B-tree value is greater than maximum list value"); - } /* end if */ - else if(max_list > H5O_SHMESG_MAX_LIST_SIZE) { - h5badArgument(env, "H5Pset_shared_mesg_phase_change: max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); - } /* end else if */ - else if(min_btree > H5O_SHMESG_MAX_LIST_SIZE) { - h5badArgument(env, "H5Pset_shared_mesg_phase_change: min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); - } /* end else if */ - else { - retVal = H5Pset_shared_mesg_phase_change((hid_t)fcpl_id, (unsigned)max_list, (unsigned)min_btree); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_nindexes - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes - (JNIEnv *env, jclass clss, jlong fcpl_id) -{ - unsigned nindexes; - - if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) - h5libraryError(env); - - return (jint)nindexes; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_nindexes - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes - (JNIEnv *env, jclass clss, jlong plist_id, jint nindexes) -{ - herr_t retVal = -1; - - if (nindexes > H5O_SHMESG_MAX_NINDEXES) { - h5badArgument(env, "H5Pset_shared_mesg_nindexes: number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); - } /* end if */ - else { - retVal = H5Pset_shared_mesg_nindexes((hid_t)plist_id, (unsigned)nindexes); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_index - * Signature: (JIII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index - (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, - jint mesg_type_flags, jint min_mesg_size) -{ - herr_t retVal = -1; - unsigned nindexes;/* Number of SOHM indexes */ - - /* Check arguments */ - if(mesg_type_flags > H5O_SHMESG_ALL_FLAG) { - h5badArgument(env, "H5Pset_shared_mesg_index: unrecognized flags in mesg_type_flags"); - } /* end if */ - else if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes) < 0) { /* Read the current number of indexes */ - h5libraryError(env); - } /* end else if */ - else { - /* Range check */ - if((unsigned)index_num >= nindexes) { - h5badArgument(env, "H5Pset_shared_mesg_index: index_num is too large; no such index"); - } /* end if */ - else { - retVal = H5Pset_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, (unsigned) mesg_type_flags, (unsigned) min_mesg_size); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_index - * Signature: (JI[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index - (JNIEnv *env, jclass clss, jlong fcpl_id, jint index_num, jintArray mesg_info) -{ - herr_t retVal = -1; - unsigned nindexes;/* Number of SOHM indexes */ - unsigned *theArray = NULL; - jboolean isCopy; - - /* Read the current number of indexes */ - if(H5Pget_shared_mesg_nindexes((hid_t)fcpl_id, &nindexes)<0) { - h5libraryError(env); - } /* end if */ - else { - /* Range check */ - if((unsigned)index_num >= nindexes) { - h5badArgument(env, "H5Pget_shared_mesg_index: index_num is too large; no such index"); - } /* end if */ - else if (mesg_info == NULL) { - h5nullArgument(env, "H5Pget_shared_mesg_index: mesg_info is NULL"); - } /* end else if */ - else { - theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR mesg_info, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_shared_mesg_index: input not pinned"); - } /* end if */ - else { - retVal = H5Pget_shared_mesg_index((hid_t)fcpl_id, (unsigned)index_num, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR mesg_info, (jint*)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR mesg_info, (jint*)theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_local_heap_size_hint - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint - (JNIEnv *env, jclass clss, jlong gcpl_id, jlong size_hint) -{ - herr_t retVal = -1; - - retVal = H5Pset_local_heap_size_hint((hid_t)gcpl_id, (size_t)size_hint); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_local_heap_size_hint - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint - (JNIEnv *env, jclass clss, jlong gcpl_id) -{ - size_t size_hint; - - if(H5Pget_local_heap_size_hint((hid_t)gcpl_id, &size_hint) < 0) - h5libraryError(env); - - return (jlong)size_hint; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_nbit - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nbit - (JNIEnv *env, jclass clss, jlong plist_id) -{ - herr_t retVal = -1; - - retVal = H5Pset_nbit((hid_t)plist_id); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1nbit */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_scaleoffset - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset - (JNIEnv *env, jclass clss, jlong plist_id, jint scale_type, jint scale_factor) -{ - herr_t retVal = -1; - - /* Check arguments */ - if(scale_factor < 0) { - h5badArgument(env, "H5Pset_scaleoffset: scale factor must be > 0"); - } /* end if */ - else { - if(scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT){ - h5badArgument(env, "H5Pset_scaleoffset: invalid scale type"); - } /* end if */ - else { - retVal = H5Pset_scaleoffset((hid_t)plist_id, (H5Z_SO_scale_type_t)scale_type, scale_factor); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_est_link_info - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info - (JNIEnv *env, jclass clss, jlong gcpl_id, jint est_num_entries, jint est_name_len) -{ - herr_t retVal = -1; - - /* Range check values */ - if((est_num_entries > 65535) || (est_name_len > 65535)) { - h5badArgument(env, "H5Pset_est_link_info: est. name length or number of entries must be < 65536"); - } /* end if */ - else { - retVal = H5Pset_est_link_info((hid_t)gcpl_id, (unsigned)est_num_entries, (unsigned)est_name_len); - if(retVal < 0) - h5libraryError(env); - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_est_link_info - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info - (JNIEnv *env, jclass clss, jlong gcpl_id, jintArray link_info) -{ - herr_t retVal = -1; - unsigned *theArray = NULL; - jboolean isCopy; - - if (link_info == NULL) { - h5nullArgument(env, "H5Pget_est_link_info: link_info is NULL"); - } /* end if */ - else { - theArray = (unsigned *)ENVPTR->GetIntArrayElements(ENVPAR link_info,&isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_est_link_info: input not pinned"); - } /* end if */ - else { - retVal= H5Pget_est_link_info((hid_t)gcpl_id, &(theArray[0]), &(theArray[1])); - if(retVal < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR link_info, (jint *)theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR link_info, (jint *)theArray, 0); - } /* end else */ - } /* end else */ - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_fapl - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl - (JNIEnv *env, jclass clss, jlong lapl_id, jlong fapl_id) -{ - herr_t retVal = -1; - - retVal = H5Pset_elink_fapl((hid_t)lapl_id, (hid_t)fapl_id); - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pget_elink_fapl - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl - (JNIEnv *env, jclass clss, jlong lapl_id) -{ - hid_t retVal = -1; - - retVal = H5Pget_elink_fapl((hid_t)lapl_id); - if (retVal < 0) - h5libraryError(env); - - return (jlong)retVal; -} /* end Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_prefix - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix - (JNIEnv *env, jclass clss, jlong lapl_id, jstring prefix) -{ - herr_t retVal = -1; - const char *aName; - - PIN_JAVA_STRING(prefix, aName); - if (aName != NULL) { - retVal = H5Pset_elink_prefix((hid_t)lapl_id, aName); - - UNPIN_JAVA_STRING(prefix, aName); - - if(retVal < 0) - h5libraryError(env); - } - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_prefix - * Signature: (J[Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix - (JNIEnv *env, jclass clss, jlong lapl_id, jobjectArray prefix) -{ - size_t size = 0; - char *pre; - jlong prefix_size = -1; - jstring str = NULL; - - if (prefix == NULL) { - h5nullArgument(env, "H5Pget_elink_prefix: prefix is NULL"); - } /* end if */ - else { - prefix_size = (jlong)H5Pget_elink_prefix((hid_t)lapl_id, (char*)NULL, size); - if(prefix_size < 0) { - h5libraryError(env); - } /* end if */ - else { - size = (size_t)prefix_size + 1;/* add extra space for the null terminator */ - pre = (char*)HDmalloc(sizeof(char)*size); - if (pre == NULL) { - h5outOfMemory(env, "H5Pget_elink_prefix: malloc failed "); - } /* end if */ - else { - prefix_size = (jlong)H5Pget_elink_prefix((hid_t)lapl_id, (char*)pre, size); - - if (prefix_size < 0) { - HDfree(pre); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR pre); - HDfree(pre); - if (str == NULL) { - h5JNIFatalError(env, "H5Pget_elink_prefix: return string not created"); - } /* end if */ - else - ENVPTR->SetObjectArrayElement(ENVPAR prefix, 0, str); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - - return prefix_size; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_direct - * Signature: (JJJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct - (JNIEnv *env, jclass clss, jlong fapl_id, jlong alignment, - jlong block_size, jlong cbuf_size) -{ - herr_t retVal = -1; - -#ifdef H5_HAVE_DIRECT - retVal = H5Pset_fapl_direct((hid_t)fapl_id, (size_t)alignment, (size_t)block_size, (size_t)cbuf_size); -#endif - if(retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_direct - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct - (JNIEnv *env, jclass clss, jlong fapl_id, jlongArray info) -{ - herr_t retVal = -1; - -#ifdef H5_HAVE_DIRECT - size_t alignment = 0; - size_t block_size = 0; - size_t cbuf_size = 0; - jlong *theArray; - jboolean isCopy; - if (info == NULL) { - h5nullArgument(env, "H5Pget_fapl_direct: info input array is NULL"); - } /* end if */ - else { - if (ENVPTR->GetArrayLength(ENVPAR info) < 3) { - h5badArgument( env, "H5Pget_fapl_direct: info input array < 4"); - } /* end if */ - else { - theArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR info, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Pget_fapl_direct: info not pinned"); - } /* end if */ - else { - retVal = H5Pget_fapl_direct((hid_t)fapl_id, &alignment, &block_size, &cbuf_size); - if(retVal < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR info, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - theArray[0] = (jlong)alignment; - theArray[1] = (jlong)block_size; - theArray[2] = (jlong)cbuf_size; - ENVPTR->ReleaseLongArrayElements(ENVPAR info, theArray, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ -#else - if (retVal < 0) - h5libraryError(env); -#endif - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_sec2 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - herr_t retVal = -1; - - retVal = H5Pset_fapl_sec2((hid_t) fapl_id); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_stdio - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - herr_t retVal = -1; - - retVal = H5Pset_fapl_stdio((hid_t) fapl_id); - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_windows - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - herr_t retVal = -1; - -#ifdef H5_HAVE_WINDOWS - retVal = H5Pset_fapl_windows((hid_t) fapl_id); -#endif - if (retVal < 0) - h5libraryError(env); - - return (jint)retVal; -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_muti - * Signature: (J[I[J[Ljava/lang/String;[J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi - (JNIEnv *env, jclass clss, jlong tid, jintArray memb_map, - jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr) -{ - herr_t status = -1; - int i; - jint *themapArray = NULL; - jlong *thefaplArray = NULL; - jlong *theaddrArray = NULL; - char **mName = NULL; - jstring str; - jboolean isCopy; - int relax = 0; - - if (memb_map) { - themapArray = (jint*)ENVPTR->GetIntArrayElements(ENVPAR memb_map, &isCopy); - if (themapArray == NULL) { - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_map not pinned"); - return 0; - } /* end if */ - } /* end if */ - - if (memb_fapl) { - thefaplArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR memb_fapl, &isCopy); - if (thefaplArray == NULL) { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_fapl not pinned"); - return 0; - } /* end if */ - } /* end if */ - - if (memb_addr) { - theaddrArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR memb_addr, &isCopy); - if (theaddrArray == NULL) { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_addr not pinned"); - return 0; - } /* end if */ - } /* end if */ - - if (memb_name) - mName = (char**)HDcalloc(H5FD_MEM_NTYPES, sizeof (*mName)); - - status = H5Pget_fapl_multi((hid_t)tid, (H5FD_mem_t*)themapArray, (hid_t*)thefaplArray, mName, (haddr_t*)theaddrArray, (hbool_t*)&relax); - - if (status < 0) { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); - if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, JNI_ABORT); - if (memb_name) h5str_array_free(mName, H5FD_MEM_NTYPES); - h5libraryError(env); - } /* end if */ - else { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, 0); - if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, 0); - if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, 0); - - if (memb_name) { - if (mName) { - for (i = 0; i < H5FD_MEM_NTYPES; i++) { - if (*(mName + i)) { - str = ENVPTR->NewStringUTF(ENVPAR *(mName+i)); - ENVPTR->SetObjectArrayElement(ENVPAR memb_name, i, (jobject)str); - } /* end if */ - } /* for (i=0; iGetIntArrayElements(ENVPAR memb_map, &isCopy); - if (themapArray == NULL) { - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_map not pinned"); - return; - } /* end if */ - } /* end if */ - - if (memb_fapl) { - thefaplArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_fapl, &isCopy); - if (thefaplArray == NULL) { - if (memb_map) - ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_fapl not pinned"); - return; - } /* end if */ - } /* end if */ - - if (memb_addr) { - theaddrArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR memb_addr, &isCopy); - if (theaddrArray == NULL) { - if (memb_map) - ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - if (memb_fapl) - ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_fapl_muti: memb_addr not pinned"); - return; - } /* end if */ - } /* end if */ - - HDmemset(member_name, 0, H5FD_MEM_NTYPES * sizeof(char*)); - if (memb_name) { - int i; - for (i = 0; i < H5FD_MEM_NTYPES; i++) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) memb_name, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); - - if (utf8) { - member_name[i] = (char*)HDmalloc(HDstrlen(utf8) + 1); - if (member_name[i]) { - strcpy(member_name[i], utf8); - } /* end if */ - } /* end if */ - - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); - } /* end if */ - } /* end for */ - mName = (const char **)member_name; - } /* end if */ - - status = H5Pset_fapl_multi((hid_t)tid, (const H5FD_mem_t *)themapArray, (const hid_t *)thefaplArray, mName, (const haddr_t *)theaddrArray, (hbool_t)relax); - - if (status < 0) { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, JNI_ABORT); - if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, JNI_ABORT); - if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, JNI_ABORT); - if (memb_name) { - int i; - for (i = 0; i < H5FD_MEM_NTYPES; i++) - HDfree(member_name[i]); - } /* end if */ - h5libraryError(env); - } /* end if */ - else { - if (memb_map) ENVPTR->ReleaseIntArrayElements(ENVPAR memb_map, themapArray, 0); - if (memb_fapl) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_fapl, thefaplArray, 0); - if (memb_addr) ENVPTR->ReleaseLongArrayElements(ENVPAR memb_addr, theaddrArray, 0); - if (memb_name) { - if (mName != NULL) { - int i; - Sjc = ENVPTR->FindClass(ENVPAR "java/lang/String"); - if (Sjc != NULL) { - for (i = 0; i < H5FD_MEM_NTYPES; i++) { - rstring = ENVPTR->NewStringUTF(ENVPAR member_name[i]); - o = ENVPTR->GetObjectArrayElement(ENVPAR memb_name, i); - if (o != NULL) { - bb = ENVPTR->IsInstanceOf(ENVPAR o, Sjc); - if (bb == JNI_TRUE) { - ENVPTR->SetObjectArrayElement(ENVPAR memb_name, i, (jobject)rstring); - } /* end if */ - ENVPTR->DeleteLocalRef(ENVPAR o); - } /* end if */ - HDfree(member_name[i]); - } /* end for */ - } /* end if */ - } /* end if */ - } /* end if */ - } /* end else */ -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_split - * Signature: (JLjava/lang/String;JLjava/lang/String;J)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split - (JNIEnv *env, jclass clss, jlong fapl_id, jstring metaext, jlong meta_pl_id, jstring rawext, jlong raw_pl_id) -{ - herr_t retVal = -1; - const char *mstr; - const char *rstr; - - PIN_JAVA_STRING_TWO(metaext, mstr, rawext, rstr); - if (mstr != NULL && rstr != NULL) { - retVal = H5Pset_fapl_split((hid_t)fapl_id, mstr, (hid_t)meta_pl_id, rstr, (hid_t)raw_pl_id); - - UNPIN_JAVA_STRING_TWO(metaext, mstr, rawext, rstr); - - if (retVal < 0) - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_meta_block_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) -{ - long sz = (long)size; - - if (H5Pset_meta_block_size((hid_t)plist, (hsize_t)sz) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_meta_block_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size - (JNIEnv *env, jclass clss, jlong plist) -{ - hsize_t s; - - if (H5Pget_meta_block_size((hid_t)plist, &s) < 0) - h5libraryError(env); - - return (jlong)s; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sieve_buf_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size - (JNIEnv *env, jclass clss, jlong plist, jlong size) -{ - size_t sz = (size_t)size; - - if (H5Pset_sieve_buf_size((hid_t)plist, (size_t)sz) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sieve_buf_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size - (JNIEnv *env, jclass clss, jlong plist) -{ - size_t s; - - if (H5Pget_sieve_buf_size((hid_t)plist, &s) < 0) - h5libraryError(env); - - return (jlong)s; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_file_cache_size - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size - (JNIEnv *env, jclass clss, jlong plist, jint size) -{ - unsigned sz = (unsigned)size; - - if (H5Pset_elink_file_cache_size((hid_t)plist, (unsigned)sz) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_file_cache_size - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size - (JNIEnv *env, jclass clss, jlong plist) -{ - unsigned s; - - if (H5Pget_elink_file_cache_size((hid_t)plist, &s) < 0) - h5libraryError(env); - - return (jint)s; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size */ - - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_mdc_config - * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; - */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config - (JNIEnv *env, jclass clss, jlong plist) -{ - H5AC_cache_config_t cacheinfo; - herr_t status = -1; - jvalue args[30]; - jstring j_str = NULL; - jobject ret_obj = NULL; - - HDmemset(&cacheinfo, 0, sizeof(H5AC_cache_config_t)); - cacheinfo.version = H5AC__CURR_CACHE_CONFIG_VERSION; - - status = H5Pget_mdc_config((hid_t)plist, &cacheinfo); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - args[0].i = cacheinfo.version; - args[1].z = cacheinfo.rpt_fcn_enabled; - args[2].z = cacheinfo.open_trace_file; - args[3].z = cacheinfo.close_trace_file; - if (cacheinfo.trace_file_name != NULL) { - j_str = ENVPTR->NewStringUTF(ENVPAR cacheinfo.trace_file_name); - } /* end if */ - args[4].l = j_str; - args[5].z = cacheinfo.evictions_enabled; - args[6].z = cacheinfo.set_initial_size; - args[7].j = (jlong)cacheinfo.initial_size; - args[8].d = cacheinfo.min_clean_fraction; - args[9].j = (jlong)cacheinfo.max_size; - args[10].j = (jlong)cacheinfo.min_size; - args[11].j = cacheinfo.epoch_length; - args[12].i = cacheinfo.incr_mode; - args[13].d = cacheinfo.lower_hr_threshold; - args[14].d = cacheinfo.increment; - args[15].z = cacheinfo.apply_max_increment; - args[16].j = (jlong)cacheinfo.max_increment; - args[17].i = cacheinfo.flash_incr_mode; - args[18].d = cacheinfo.flash_multiple; - args[19].d = cacheinfo.flash_threshold; - args[20].i = cacheinfo.decr_mode; - args[21].d = cacheinfo.upper_hr_threshold; - args[22].d = cacheinfo.decrement; - args[23].z = cacheinfo.apply_max_decrement; - args[24].j = (jlong)cacheinfo.max_decrement; - args[25].i = cacheinfo.epochs_before_eviction; - args[26].z = cacheinfo.apply_empty_reserve; - args[27].d = cacheinfo.empty_reserve; - args[28].j = (jlong)cacheinfo.dirty_bytes_threshold; - args[29].i = cacheinfo.metadata_write_strategy; - CALL_CONSTRUCTOR("hdf/hdf5lib/structs/H5AC_cache_config_t", "(IZZZLjava/lang/String;ZZJDJJJIDDZJIDDIDDZJIZDJI)V", args); - } /* end else */ - return ret_obj; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_mdc_config - * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config - (JNIEnv *env, jclass clss, jlong plist, jobject cache_config) -{ - herr_t status = -1; - jclass cls; - jfieldID fid; - jstring j_str; - const char *str; - H5AC_cache_config_t cacheinfo; - - cls = ENVPTR->GetObjectClass(ENVPAR cache_config); - fid = ENVPTR->GetFieldID(ENVPAR cls, "version", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: version"); - return; - } /* end if */ - cacheinfo.version = ENVPTR->GetIntField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading version failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "rpt_fcn_enabled", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: rpt_fcn_enabled"); - return; - } /* end if */ - cacheinfo.rpt_fcn_enabled = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading rpt_fcn_enabled failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "open_trace_file", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: open_trace_file"); - return; - } /* end if */ - cacheinfo.open_trace_file = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading open_trace_file failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "close_trace_file", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: close_trace_file"); - return; - } /* end if */ - cacheinfo.close_trace_file = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading close_trace_file failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "trace_file_name", "Ljava/lang/String;"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: trace_file_name"); - return; - } /* end if */ - j_str = (jstring)ENVPTR->GetObjectField(ENVPAR cache_config, fid); - str = ENVPTR->GetStringUTFChars(ENVPAR j_str, NULL); - if (str == NULL) { - h5JNIFatalError(env, "H5Pset_mdc_config: out of memory trace_file_name"); - return; - } /* end if */ - HDstrncpy(cacheinfo.trace_file_name, str, 1025); - ENVPTR->ReleaseStringUTFChars(ENVPAR j_str, str); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading trace_file_name failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "evictions_enabled", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: evictions_enabled"); - return; - } /* end if */ - cacheinfo.evictions_enabled = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading evictions_enabled failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "set_initial_size", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: set_initial_size"); - return; - } /* end if */ - cacheinfo.set_initial_size = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading set_initial_size failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "initial_size", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: initial_size"); - return; - } /* end if */ - cacheinfo.initial_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading initial_size failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "min_clean_fraction", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: min_clean_fraction"); - return; - } /* end if */ - cacheinfo.min_clean_fraction = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading min_clean_fraction failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "max_size", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: max_size"); - return; - } /* end if */ - cacheinfo.max_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading max_size failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "min_size", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: min_size"); - return; - } /* end if */ - cacheinfo.min_size = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading min_size failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "epoch_length", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: epoch_length"); - return; - } - cacheinfo.epoch_length = (long int)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading epoch_length failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "incr_mode", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: incr_mode"); - return; - } /* end if */ - cacheinfo.incr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_incr_mode) */ - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading incr_mode failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "lower_hr_threshold", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: lower_hr_threshold"); - return; - } /* end if */ - cacheinfo.lower_hr_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading lower_hr_threshold failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "increment", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: increment"); - return; - } /* end if */ - cacheinfo.increment = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading increment failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_max_increment", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: apply_max_increment"); - return; - } /* end if */ - cacheinfo.apply_max_increment = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_max_increment failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "max_increment", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: max_increment"); - return; - } /* end if */ - cacheinfo.max_increment = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading max_increment failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_incr_mode", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: flash_incr_mode"); - return; - } /* end if */ - cacheinfo.flash_incr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_flash_incr_mode) */ - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_incr_mode failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_multiple", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: flash_multiple"); - return; - } /* end if */ - cacheinfo.flash_multiple = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_multiple failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "flash_threshold", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: flash_threshold"); - return; - } /* end if */ - cacheinfo.flash_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading flash_threshold failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "decr_mode", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: decr_mode"); - return; - } /* end if */ - cacheinfo.decr_mode = ENVPTR->GetIntField(ENVPAR cache_config, fid); /*(enum H5C_cache_decr_mode) */ - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading decr_mode failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "upper_hr_threshold", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: upper_hr_threshold"); - return; - } /* end if */ - cacheinfo.upper_hr_threshold = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading upper_hr_threshold failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "decrement", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: decrement"); - return; - } /* end if */ - cacheinfo.decrement = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading decrement failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_max_decrement", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: apply_max_decrement"); - return; - } /* end if */ - cacheinfo.apply_max_decrement = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_max_decrement failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "max_decrement", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: max_decrement"); - return; - } /* end if */ - cacheinfo.max_decrement = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading max_decrement failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "epochs_before_eviction", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: epochs_before_eviction"); - return; - } /* end if */ - cacheinfo.epochs_before_eviction = ENVPTR->GetIntField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading epochs_before_eviction failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "apply_empty_reserve", "Z"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: apply_empty_reserve"); - return; - } /* end if */ - cacheinfo.apply_empty_reserve = ENVPTR->GetBooleanField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading apply_empty_reserve failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "empty_reserve", "D"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: empty_reserve"); - return; - } /* end if */ - cacheinfo.empty_reserve = ENVPTR->GetDoubleField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading empty_reserve failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "dirty_bytes_threshold", "J"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: dirty_bytes_threshold"); - return; - } /* end if */ - cacheinfo.dirty_bytes_threshold = (size_t)ENVPTR->GetLongField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading dirty_bytes_threshold failed"); - return; - } /* end if */ - - fid = ENVPTR->GetFieldID(ENVPAR cls, "metadata_write_strategy", "I"); - if(fid == 0) { - h5badArgument(env, "H5Pset_mdc_config: metadata_write_strategy"); - return; - } /* end if */ - cacheinfo.metadata_write_strategy = ENVPTR->GetIntField(ENVPAR cache_config, fid); - if(ENVPTR->ExceptionOccurred(ENVONLY)) { - h5JNIFatalError(env, "H5Pset_mdc_config: loading metadata_write_strategy failed"); - } /* end if */ - else { - status = H5Pset_mdc_config((hid_t)plist, &cacheinfo); - - if (status < 0) - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk_cache - * Signature: (JJJD)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache - (JNIEnv *env, jclass clss, jlong dapl, jlong rdcc_nslots, - jlong rdcc_nbytes, jdouble rdcc_w0) -{ - if (H5Pset_chunk_cache((hid_t)dapl, (size_t)rdcc_nslots, (size_t)rdcc_nbytes, (double) rdcc_w0) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk_cache - * Signature: (J[J[J[D)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache - (JNIEnv *env, jclass clss, jlong dapl, jlongArray rdcc_nslots, - jlongArray rdcc_nbytes, jdoubleArray rdcc_w0) -{ - herr_t status = -1; - jint mode; - jdouble *w0Array = (jdouble *)NULL; - jlong *rdcc_nslotsArray = (jlong *)NULL; - jlong *nbytesArray = (jlong *)NULL; - jboolean isCopy; - - if (rdcc_w0 != NULL) { - w0Array = (jdouble *)ENVPTR->GetDoubleArrayElements(ENVPAR rdcc_w0, &isCopy); - if (w0Array == NULL) { - h5JNIFatalError(env, "H5Pget_chunk_cache: w0_array array not pinned"); - return; - } /* end if */ - } /* end else */ - - if (rdcc_nslots != NULL) { - rdcc_nslotsArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nslots, &isCopy); - if (rdcc_nslotsArray == NULL) { - /* exception -- out of memory */ - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); - } /* end if */ - h5JNIFatalError(env, "H5Pget_chunk_cache: rdcc_nslots array not pinned"); - return; - } /* end if */ - } /* end else */ - - if (rdcc_nbytes != NULL) { - nbytesArray = (jlong *)ENVPTR->GetLongArrayElements(ENVPAR rdcc_nbytes, &isCopy); - if (nbytesArray == NULL) { - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, JNI_ABORT); - } /* end if */ - if (rdcc_nslotsArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nslots, rdcc_nslotsArray, JNI_ABORT); - } /* end if */ - h5JNIFatalError(env, "H5Pget_chunk_cache: nbytesArray array not pinned"); - return; - } /* end if */ - } /* end else */ - - { /* direct cast (size_t *)variable fails on 32-bit environment */ - long long rdcc_nslots_temp = *(rdcc_nslotsArray); - size_t rdcc_nslots_t = (size_t)rdcc_nslots_temp; - long long nbytes_temp = *(nbytesArray); - size_t nbytes_t = (size_t)nbytes_temp; - - status = H5Pget_chunk_cache((hid_t)dapl, &rdcc_nslots_t, &nbytes_t, (double *)w0Array); - - *rdcc_nslotsArray = (jlong)rdcc_nslots_t; - *nbytesArray = (jlong)nbytes_t; - } /* end direct cast special handling */ - - if (status < 0) { - mode = JNI_ABORT; - } /* end if */ - else { - mode = 0; /* commit and free */ - } /* end else */ - - if (rdcc_nslotsArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nslots, rdcc_nslotsArray, mode); - } - /* end if */ - if (nbytesArray != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR rdcc_nbytes, nbytesArray, mode); - } /* end if */ - - if (w0Array != NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rdcc_w0, w0Array, mode); - } /* end if */ - - if (status < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_obj_track_times - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times - (JNIEnv *env, jclass clss, jlong objplid) -{ - hbool_t track_times; - - if (H5Pget_obj_track_times((hid_t)objplid, &track_times) < 0) { - h5libraryError(env); - return JNI_FALSE; - } /* end if */ - if (track_times == 1) { - return JNI_TRUE; - } /* end if */ - return JNI_FALSE; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_obj_track_times - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times - (JNIEnv *env, jclass clss, jlong objplid, jboolean track_times) -{ - hbool_t track; - - if (track_times == JNI_TRUE) { - track = 1; - } /* end if */ - else { - track = 0; - } /* end else */ - - if (H5Pset_obj_track_times((hid_t)objplid, track) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_char_encoding - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding - (JNIEnv *env, jclass clss, jlong acpl) -{ - H5T_cset_t encoding; - - if (H5Pget_char_encoding((hid_t)acpl, &encoding) < 0) - h5libraryError(env); - - return encoding; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_char_encoding - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding - (JNIEnv *env, jclass clss, jlong acpl, jint encoding) -{ - if (H5Pset_char_encoding((hid_t)acpl, (H5T_cset_t)encoding) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual - * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong vspace_id, - jstring src_file_name, jstring src_dset_name, jlong src_space_id) -{ - herr_t retVal = -1; - const char *fstr; - const char *dstr; - - PIN_JAVA_STRING_TWO(src_file_name, fstr, src_dset_name, dstr); - if (fstr != NULL && dstr != NULL) { - retVal = H5Pset_virtual((hid_t)dcpl_id, (hid_t)vspace_id, fstr, dstr, (hid_t)src_space_id); - - UNPIN_JAVA_STRING_TWO(src_file_name, fstr, src_dset_name, dstr); - - if (retVal < 0) - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_count - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count - (JNIEnv *env, jclass clss, jlong dcpl_id) -{ - size_t s; - - if (H5Pget_virtual_count((hid_t)dcpl_id, &s) < 0) - h5libraryError(env); - - return (jlong)s; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_vspace - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) -{ - hid_t space_id = -1; - - space_id = H5Pget_virtual_vspace((hid_t)dcpl_id, (size_t)index); - if (space_id < 0) - h5libraryError(env); - - return (jlong)space_id; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_srcspace - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) -{ - hid_t space_id = -1; - - space_id = H5Pget_virtual_srcspace((hid_t)dcpl_id, (size_t)index); - if (space_id < 0) - h5libraryError(env); - - return (jlong)space_id; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_filename - * Signature: (JJ)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) -{ - char *fname; - ssize_t buf_size; - ssize_t status; - jstring str = NULL; - - /* get the length of the filename */ - buf_size = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, NULL, 0); - if (buf_size < 0) { - h5badArgument( env, "H5Pget_virtual_filename: buf_size < 0"); - } /* end if */ - else if (buf_size >= 0) { - buf_size++; /* add extra space for the null terminator */ - fname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); - if (fname == NULL) { - h5outOfMemory( env, "H5Pget_virtual_filename: malloc failed"); - } /* end if */ - else { - status = H5Pget_virtual_filename((hid_t)dcpl_id, (size_t)index, fname, (size_t)buf_size); - - if (status >= 0) { - str = ENVPTR->NewStringUTF(ENVPAR fname); - HDfree(fname); - if (str == NULL) - h5JNIFatalError( env, "H5Pget_virtual_filename: return string not allocated"); - } /* end if */ - else { - HDfree(fname); - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else if */ - - return (jstring)str; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_dsetname - * Signature: (JJ)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname - (JNIEnv *env, jclass clss, jlong dcpl_id, jlong index) -{ - char *dname; - ssize_t buf_size; - ssize_t status; - jstring str = NULL; - - /* get the length of the filename */ - buf_size = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, NULL, 0); - if (buf_size < 0) { - h5badArgument( env, "H5Pget_virtual_dsetname: buf_size < 0"); - } /* end if */ - else if (buf_size > 0) { - buf_size++; /* add extra space for the null terminator */ - dname = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); - if (dname == NULL) { - h5outOfMemory( env, "H5Pget_virtual_dsetname: malloc failed"); - } /* end if */ - else { - status = H5Pget_virtual_dsetname((hid_t)dcpl_id, (size_t)index, dname, (size_t)buf_size); - - if (status >= 0) { - str = ENVPTR->NewStringUTF(ENVPAR dname); - HDfree(dname); - if (str == NULL) - h5JNIFatalError( env, "H5Pget_virtual_dsetname: return string not allocated"); - } /* end if */ - else { - HDfree(dname); - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else if */ - return (jstring)str; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_view - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view - (JNIEnv *env, jclass clss, jlong dapl_id) -{ - H5D_vds_view_t virtual_view; - - if (H5Pget_virtual_view((hid_t)dapl_id, &virtual_view) < 0) - h5libraryError(env); - - return (jint)virtual_view; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_view - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view - (JNIEnv *env, jclass clss, jlong dapl_id, jint view) -{ - if (H5Pset_virtual_view((hid_t)dapl_id, (H5D_vds_view_t)view) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_printf_gap - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap - (JNIEnv *env, jclass clss, jlong dapl_id) -{ - hsize_t gap_size; - - if (H5Pget_virtual_printf_gap((hid_t)dapl_id, &gap_size) < 0) - h5libraryError(env); - - return (jlong)gap_size; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_printf_gap - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap - (JNIEnv *env, jclass clss, jlong dapl_id, jlong gap_size) -{ - if (H5Pset_virtual_printf_gap((hid_t)dapl_id, (hsize_t)gap_size) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy - * Signature: (J[Z[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy - (JNIEnv *env, jclass clss, jlong fcpl_id, jbooleanArray persist, jlongArray threshold) -{ - herr_t status = -1; - H5F_fspace_strategy_t thestrategy = H5F_FSPACE_STRATEGY_FSM_AGGR; /* Library default */ - jlong *thethresholdArray = NULL; - jboolean *thepersistArray = NULL; - jboolean isCopy; - - if (persist) { - thepersistArray = (jboolean*)ENVPTR->GetBooleanArrayElements(ENVPAR persist, &isCopy); - if (thepersistArray == NULL) { - h5JNIFatalError(env, "H5Pget_file_space: persist not pinned"); - return -1; - } - } - - if (threshold) { - thethresholdArray = (jlong*)ENVPTR->GetLongArrayElements(ENVPAR threshold, &isCopy); - if (thethresholdArray == NULL) { - if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, JNI_ABORT); - h5JNIFatalError(env, "H5Pget_file_space: threshold not pinned"); - return -1; - } /* end if */ - } /* end if */ - - status = H5Pget_file_space_strategy((hid_t)fcpl_id, &thestrategy, (hbool_t*)thepersistArray, (hsize_t*)thethresholdArray); - - if (status < 0) { - if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, JNI_ABORT); - if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - if (persist) ENVPTR->ReleaseBooleanArrayElements(ENVPAR persist, thepersistArray, 0); - if (threshold) ENVPTR->ReleaseLongArrayElements(ENVPAR threshold, thethresholdArray, 0); - } /* end else */ - return (jint)thestrategy; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy_persist - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist - (JNIEnv *env, jclass clss, jlong fcpl_id) -{ - herr_t status = -1; - hbool_t thepersist = FALSE; - - status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, &thepersist, NULL); - - if (status < 0) - h5libraryError(env); - - return (jboolean)thepersist; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy_threshold - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold - (JNIEnv *env, jclass clss, jlong fcpl_id) -{ - herr_t status = -1; - hsize_t thethreshold; - - status = H5Pget_file_space_strategy((hid_t)fcpl_id, NULL, NULL, &thethreshold); - - if (status < 0) - h5libraryError(env); - - return (jlong)thethreshold; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1threshold */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space_strategy - * Signature: (JIZJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy - (JNIEnv *env, jclass clss, jlong fcpl_id, jint strategy, jboolean persist, jlong threshold) -{ - if (H5Pset_file_space_strategy((hid_t)fcpl_id, (H5F_fspace_strategy_t)strategy, (hbool_t)persist, (hsize_t)threshold) < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_file_space_strategy */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space_page_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size - (JNIEnv *env, jclass clss, jlong fcpl_id, jlong fsp_size) -{ - if (H5Pset_file_space_page_size((hid_t)fcpl_id, (hsize_t)fsp_size) < 0) - h5libraryError(env); -} - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_page_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size - (JNIEnv *env, jclass clss, jlong fcpl_id) -{ - hsize_t fsp_size = 0; - if (H5Pget_file_space_page_size((hid_t)fcpl_id, &fsp_size) < 0) - h5libraryError(env); - return (jlong)fsp_size; -} - -static herr_t -H5P_cls_create_cb - (hid_t prop_id, void *create_data) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_create_func_t;)I"); - if (mid != 0) { - /* fprintf(stderr, "JNI H5P_cls_create_func_cb execute\n"); fflush(stderr); */ - status = CBENVPTR->CallIntMethod(CBENVPAR create_callback, mid, prop_id, create_data); - /* fprintf(stderr, "\nJNI H5P_cls_create_func_cb status: %d\n", status); fflush(stderr); */ - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_cls_create_cb */ - -static herr_t -H5P_cls_copy_cb - (hid_t new_prop_id, hid_t old_prop_id, void *copy_data) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JJLhdf/hdf5lib/callbacks/H5P_cls_copy_func_t;)I"); - if (mid != 0) { - status = CBENVPTR->CallIntMethod(CBENVPAR copy_callback, mid, new_prop_id, old_prop_id, copy_data); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_cls_copy_cb */ - -static herr_t -H5P_cls_close_cb - (hid_t prop_id, void *close_data) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLhdf/hdf5lib/callbacks/H5P_cls_close_func_t;)I"); - if (mid != 0) { - status = CBENVPTR->CallIntMethod(CBENVPAR close_callback, mid, prop_id, close_data); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_cls_close_cb */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_mdc_log_options - * Signature: (JZLjava/lang/String;Z)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean is_enabled, jstring location, jboolean start_on_access) -{ - herr_t retVal = -1; - const char *lstr; - - PIN_JAVA_STRING(location, lstr); - - retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, lstr, (hbool_t)start_on_access); - - UNPIN_JAVA_STRING(location, lstr); - - if (retVal < 0) { - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_mdc_log_options - * Signature: (J[Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options - (JNIEnv *env, jclass clss, jlong fapl_id, jbooleanArray mdc_log_options) -{ - hbool_t is_enabled; - hbool_t start_on_access; - jboolean *mdc_log_options_ptr; - char *lname; - size_t location_size; - ssize_t status; - jstring str = NULL; - jint size; - jboolean isCopy; - - if (mdc_log_options == NULL) { - h5nullArgument(env, "H5Fget_mdc_log_options: mdc_log_options is NULL"); - } /* end if */ - else { - size = (int)ENVPTR->GetArrayLength(ENVPAR mdc_log_options); - if (size < 2) { - h5badArgument(env, "H5Fget_mdc_log_options: length of mdc_log_options < 2."); - } /* end if */ - else { - /* get the length of the filename */ - H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, NULL, &location_size, &start_on_access); - if (location_size == 0) { - h5badArgument(env, "H5Pget_mdc_log_options: location_size is 0"); - }/* end if */ - else if (location_size > 0) { - location_size++; /* add extra space for the null terminator */ - lname = (char *)HDmalloc(sizeof(char) * location_size); - if (lname == NULL) { - h5outOfMemory(env, "H5Pget_mdc_log_options: malloc failed"); - } /* end if */ - else { - status = H5Pget_mdc_log_options((hid_t)fapl_id, &is_enabled, lname, &location_size, &start_on_access); - - if (status < 0) { - HDfree(lname); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR lname); - HDfree(lname); - if (str == NULL) { - h5JNIFatalError(env, "H5Pget_mdc_log_options: return string not allocated"); - } /* end if */ - else { - mdc_log_options_ptr = ENVPTR->GetBooleanArrayElements(ENVPAR mdc_log_options, &isCopy); - mdc_log_options_ptr[0] = (jboolean)is_enabled; - mdc_log_options_ptr[1] = (jboolean)start_on_access; - ENVPTR->ReleaseBooleanArrayElements(ENVPAR mdc_log_options, mdc_log_options_ptr, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else if*/ - } /* end else */ - } /* end else */ - - return (jstring)str; -} /* end if */ - -static herr_t -H5D_append_cb - (hid_t dataset_id, hsize_t *cur_dims, void *cb_data) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jlongArray cur_dimsArray; - cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { - JVMPTR->DetachCurrentThread(JVMPAR); - return -1; - } /* end if */ - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(J[JLhdf/hdf5lib/callbacks/H5D_append_t;)I"); - if (mid != 0) { - if (cur_dims != NULL) { - cur_dimsArray = CBENVPTR->NewLongArray(CBENVPAR 2); - if (cur_dimsArray != NULL) { - CBENVPTR->SetLongArrayRegion(CBENVPAR cur_dimsArray, 0, 2, (const jlong *)cur_dims); - - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, dataset_id, cur_dims, op_data); - } - } - } - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - - return (herr_t)status; -} /* end H5D_append_cb */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_append_flush - * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1append_1flush - (JNIEnv *env, jclass clss, jlong plist_id, jint ndims, jlongArray boundary, jobject callback_op, jobject op_data) -{ - herr_t status = -1; - cb_wrapper wrapper = {callback_op, op_data}; - - ENVPTR->GetJavaVM(ENVPAR &jvm); - - if (op_data == NULL) { - h5nullArgument(env, "H5Pset_append_flush: op_data is NULL"); - } /* end if */ - else if (callback_op == NULL) { - h5nullArgument(env, "H5Pset_append_flush: callback_op is NULL"); - } /* end if */ - else { - status = H5Pset_append_flush((hid_t)plist_id, (unsigned)ndims, (const hsize_t*)boundary, (H5D_append_cb_t)H5D_append_cb, (void*)&wrapper); - - if (status < 0) - h5libraryError(env); - } /* end else */ -} /* end Java_hdf_hdf5lib_H5_H5Pset_1append_1flush */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pcreate_class_nocb - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb - (JNIEnv *env, jclass clss, jlong parent_class, jstring name) -{ - hid_t class_id = -1; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL); - - UNPIN_JAVA_STRING(name, cstr); - - if (class_id < 0) - h5libraryError(env); - } - - return (jlong)class_id; -} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pcreate_class - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class - (JNIEnv *env, jclass clss, jlong parent_class, jstring name, jobject create_op, - jobject create_data, jobject copy_op, jobject copy_data, jobject close_op, jobject close_data) -{ - hid_t class_id = -1; - const char *cstr; - copy_callback = copy_op; - close_callback = close_op; - create_callback = create_op; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - class_id = H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, (void*) create_data, - (H5P_cls_copy_func_t)H5P_cls_copy_cb, (void*) copy_data, (H5P_cls_close_func_t)H5P_cls_close_cb, (void*) close_data); - - UNPIN_JAVA_STRING(name, cstr); - - if (class_id < 0) - h5libraryError(env); - } - - return (jlong)class_id; -} /* end Java_hdf_hdf5lib_H5__1H5Pcreate_1class */ - -static herr_t -H5P_prp_create_cb - (const char *name, size_t size, void *value) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR create_callback, mid, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_create_cb */ - -static herr_t -H5P_prp_copy_cb - (const char *name, size_t size, void *value) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR copy_callback, mid, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_copy_cb */ - -static herr_t -H5P_prp_close_cb - (const char *name, size_t size, void *value) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(Ljava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR close_callback, mid, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_close_cb */ - -static int -H5P_prp_compare_cb - (void *value1, void *value2, size_t size) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR compare_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "([B[BJ)I"); - if (mid != 0) { - status = CBENVPTR->CallIntMethod(CBENVPAR compare_callback, mid, value1, value2, size); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_compare_cb */ + status = CBENVPTR->CallIntMethod(CBENVONLY, get_callback, mid, prop_id, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -static herr_t -H5P_prp_get_cb - (hid_t prop_id, const char *name, size_t size, void *value) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR get_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR get_callback, mid, prop_id, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); return (herr_t)status; } /* end H5P_prp_get_cb */ static herr_t -H5P_prp_set_cb - (hid_t prop_id, const char *name, size_t size, void *value) -{ - JNIEnv *cbenv; - jint status = -1; - jclass cls; - jmethodID mid; - jstring str; - - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR set_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR set_callback, mid, prop_id, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_set_cb */ - -static herr_t H5P_prp_delete_cb (hid_t prop_id, const char *name, size_t size, void *value) { - JNIEnv *cbenv; - jint status = -1; - jclass cls; jmethodID mid; jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { - cls = CBENVPTR->GetObjectClass(CBENVPAR delete_callback); - if (cls != 0) { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;J[B)I"); - if (mid != 0) { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - status = CBENVPTR->CallIntMethod(CBENVPAR delete_callback, mid, prop_id, str, size, value); - } /* end if */ - } /* end if */ - } /* end if */ - JVMPTR->DetachCurrentThread(JVMPAR); - return (herr_t)status; -} /* end H5P_prp_delete_cb */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pregister2_nocb - * Signature: (JLjava/lang/String;J[B)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2_1nocb - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) -{ - herr_t status = -1; - jbyte *buffP; - jboolean isCopy2; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Pregister2: buf not pinned"); - } /* end if */ - else { - status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, cstr); + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_delete_cb: failed to attach current thread to JVM"); } -} /* end Java_hdf_hdf5lib_H5_H5Pregister2_1nocb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pregister2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2 - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, - jbyteArray def_value, jobject prp_create, jobject prp_set, jobject prp_get, jobject prp_delete, - jobject prp_copy, jobject prp_cmp, jobject prp_close) -{ - herr_t status = -1; - jbyte *buffP; - jboolean isCopy2; - const char *cstr; - copy_callback = prp_copy; - close_callback = prp_close; - create_callback = prp_create; - compare_callback = prp_cmp; - set_callback = prp_set; - get_callback = prp_get; - delete_callback = prp_delete; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, delete_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Pregister2: buf not pinned"); - } /* end if */ - else { - status = H5Pregister2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, (H5P_prp_create_func_t)H5P_prp_create_cb, - (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, - (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, cstr); - } -} /* end Java_hdf_hdf5lib_H5_H5Pregister2 */ + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pinsert2_nocb - * Signature: (JLjava/lang/String;J[B)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, jbyteArray def_value) -{ - herr_t status = -1; - jbyte *buffP; - jboolean isCopy2; - const char *cstr; - - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); - if (buffP == NULL) { - h5JNIFatalError(env, "H5Pinsert2: buf not pinned"); - } /* end if */ - else { - status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, NULL, NULL, NULL, NULL, NULL, NULL); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, cstr); - } -} /* end Java_hdf_hdf5lib_H5_H5Pinsert2 */ + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); + status = CBENVPTR->CallIntMethod(CBENVONLY, delete_callback, mid, prop_id, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pinsert2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2 - (JNIEnv *env, jclass clss, jlong cls_id, jstring name, jlong prp_size, - jbyteArray def_value, jobject prp_set, jobject prp_get, jobject prp_delete, - jobject prp_copy, jobject prp_cmp, jobject prp_close) -{ - herr_t status = -1; - jbyte *buffP; - jboolean isCopy2; - const char *cstr; - copy_callback = prp_copy; - close_callback = prp_close; - compare_callback = prp_cmp; - set_callback = prp_set; - get_callback = prp_get; - delete_callback = prp_delete; +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - PIN_JAVA_STRING(name, cstr); - if (cstr != NULL) { - buffP = ENVPTR->GetByteArrayElements(ENVPAR def_value, &isCopy2); - if (buffP == NULL) { - UNPIN_JAVA_STRING(name, cstr); - h5JNIFatalError(env, "H5Pinsert2: buf not pinned"); - } /* end if */ - else { - status = H5Pinsert2((hid_t)cls_id, cstr, (size_t)prp_size, (void*)buffP, - (H5P_prp_set_func_t)H5P_prp_set_cb, (H5P_prp_get_func_t)H5P_prp_get_cb, (H5P_prp_delete_func_t)H5P_prp_delete_cb, - (H5P_prp_copy_func_t)H5P_prp_copy_cb, (H5P_prp_compare_func_t)H5P_prp_compare_cb, (H5P_prp_close_func_t)H5P_prp_close_cb); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR def_value, buffP, 0); - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, cstr); - } -} /* end Java_hdf_hdf5lib_H5_H5Pinsert2 */ + return (herr_t)status; +} /* end H5P_prp_delete_cb */ static herr_t -H5P_iterate_cb - (hid_t prop_id, const char *name, void *cb_data) +H5P_prp_copy_cb + (const char *name, size_t size, void *value) { - JNIEnv *cbenv; - jint status = -1; - jclass cls; jmethodID mid; jstring str; - cb_wrapper *wrapper = (cb_wrapper *)cb_data; - void *op_data = (void *)wrapper->op_data; - jobject visit_callback = wrapper->visit_callback; - - /* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */ - if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { - /* fprintf(stderr, "\nJNI H5P_iterate_cb error: AttachCurrentThread failed\n"); fflush(stderr); */ - JVMPTR->DetachCurrentThread(JVMPAR); - } /* end if */ - else { - cls = CBENVPTR->GetObjectClass(CBENVPAR visit_callback); - if (cls == 0) { - /* fprintf(stderr, "\nJNI H5P_iterate_cb error: GetObjectClass failed\n"); fflush(stderr); */ - JVMPTR->DetachCurrentThread(JVMPAR); - } /* end if */ - else { - mid = CBENVPTR->GetMethodID(CBENVPAR cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/callbacks/H5P_iterate_t;)I"); - if (mid == 0) { - /* fprintf(stderr, "\nJNI H5P_iterate_cb error: GetMethodID failed\n"); fflush(stderr); */ - JVMPTR->DetachCurrentThread(JVMPAR); - } /* end if */ - else { - str = CBENVPTR->NewStringUTF(CBENVPAR name); - - /* fprintf(stderr, "JNI H5P_iterate_cb execute\n"); fflush(stderr); */ - status = CBENVPTR->CallIntMethod(CBENVPAR visit_callback, mid, prop_id, str, op_data); - /* fprintf(stderr, "\nJNI H5P_iterate_cb status: %d\n", status); fflush(stderr); */ - } /* end else */ - } /* end else */ - } /* end else */ - - JVMPTR->DetachCurrentThread(JVMPAR); - /* fprintf(stderr, "\nJNI H5P_iterate_cb leave\n"); fflush(stderr); */ + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - return status; -} /* end H5P_iterate_cb */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_copy_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Piterate - * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Piterate - (JNIEnv *env, jclass clss, jlong prop_id, jintArray idx, jobject callback_op, jobject op_data) -{ - herr_t status = -1; - jint *theArray = NULL; - jboolean isCopy; - cb_wrapper wrapper = {callback_op, op_data}; - - ENVPTR->GetJavaVM(ENVPAR &jvm); - - if (op_data == NULL) { - h5nullArgument(env, "H5Piterate: op_data is NULL"); - } /* end if */ - else if (callback_op == NULL) { - h5nullArgument(env, "H5Piterate: callback_op is NULL"); - } /* end else if */ - else { - if (idx == NULL) { - status = H5Piterate((hid_t)prop_id, NULL, (H5P_iterate_t)H5P_iterate_cb, (void*)&wrapper); - } /* end if */ - else { - theArray = (jint *)ENVPTR->GetIntArrayElements(ENVPAR idx, &isCopy); - if (theArray == NULL) { - h5JNIFatalError(env, "H5Piterate: idx not pinned"); - } /* end if */ - else - status = H5Piterate((hid_t)prop_id, (int*)&theArray[0], (H5P_iterate_t)H5P_iterate_cb, (void*)&wrapper); - } /* end else */ - - if (status < 0) { - if(idx) - ENVPTR->ReleaseIntArrayElements(ENVPAR idx, theArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else if (idx) - ENVPTR->ReleaseIntArrayElements(ENVPAR idx, theArray, 0); - } /* end else */ + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, copy_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Piterate */ + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(Ljava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_metadata_read_attempts - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts - (JNIEnv *env, jclass clss, jlong plist_id) -{ - unsigned attempts; - if (H5Pget_metadata_read_attempts((hid_t)plist_id, &attempts) < 0) - h5libraryError(env); + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return (jlong) attempts; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts */ + status = CBENVPTR->CallIntMethod(CBENVONLY, copy_callback, mid, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_metadata_read_attempts - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts - (JNIEnv *env, jclass clss, jlong plist_id, jlong attempts) -{ - if (attempts <= 0) { - h5badArgument(env, "H5Pset_metadata_read_attempts: attempts <= 0"); - } /* end if */ - else { - if(H5Pset_metadata_read_attempts((hid_t)plist_id, (unsigned)attempts) < 0) - h5libraryError(env); - } /* end else */ -} /* end Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts */ +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); + return (herr_t)status; +} /* end H5P_prp_copy_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_prefix - * Signature: (JLjava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) +static int +H5P_prp_compare_cb + (void *value1, void *value2, size_t size) { - herr_t retVal = -1; - const char *aName; - - PIN_JAVA_STRING(prefix, aName); - if (aName != NULL) { - retVal = H5Pset_virtual_prefix((hid_t)dapl_id, aName); - - UNPIN_JAVA_STRING(prefix, aName); + jmethodID mid; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - if(retVal < 0) - h5libraryError(env); + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_compare_cb: failed to attach current thread to JVM"); } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_prefix - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id) -{ - size_t size = 0; - char *pre; - jlong prefix_size = -1; - jstring str = NULL; - - prefix_size = (jlong)H5Pget_virtual_prefix((hid_t)dapl_id, (char*)NULL, size); - if(prefix_size < 0) { - h5libraryError(env); - } /* end if */ - else { - size = (size_t)prefix_size + 1;/* add extra space for the null terminator */ - pre = (char*)HDmalloc(sizeof(char)*size); - if (pre == NULL) { - h5outOfMemory(env, "H5Pget_virtual_prefix: malloc failed "); - } /* end if */ - else { - prefix_size = (jlong)H5Pget_virtual_prefix((hid_t)dapl_id, (char*)pre, size); - - if (prefix_size >= 0) { - str = ENVPTR->NewStringUTF(ENVPAR pre); - HDfree(pre); - if (str == NULL) - h5JNIFatalError( env, "H5Pget_virtual_prefix: return string not allocated"); - } /* end if */ - else { - HDfree(pre); - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ - - return (jstring)str; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_efile_prefix - * Signature: (JLjava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id, jstring prefix) -{ - herr_t retVal = -1; - const char *aName; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, compare_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - PIN_JAVA_STRING(prefix, aName); - if (aName != NULL) { - retVal = H5Pset_efile_prefix((hid_t)dapl_id, aName); + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "([B[BJ)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - UNPIN_JAVA_STRING(prefix, aName); + status = CBENVPTR->CallIntMethod(CBENVONLY, compare_callback, mid, value1, value2, size); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if(retVal < 0) - h5libraryError(env); - } -} /* end Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix */ +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_efile_prefix - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix - (JNIEnv *env, jclass clss, jlong dapl_id) -{ - size_t size = 0; - char *pre; - jlong prefix_size = -1; - jstring str = NULL; - - prefix_size = (jlong)H5Pget_efile_prefix((hid_t)dapl_id, (char*)NULL, size); - if(prefix_size < 0) { - h5libraryError(env); - } /* end if */ - else { - size = (size_t)prefix_size + 1;/* add extra space for the null terminator */ - pre = (char*)HDmalloc(sizeof(char)*size); - if (pre == NULL) { - h5outOfMemory(env, "H5Pget_efile_prefix: malloc failed "); - } /* end if */ - else { - prefix_size = (jlong)H5Pget_efile_prefix((hid_t)dapl_id, (char*)pre, size); - - if (prefix_size >= 0) { - str = ENVPTR->NewStringUTF(ENVPAR pre); - HDfree(pre); - if (str == NULL) - h5JNIFatalError( env, "H5Pget_efile_prefix: return string not allocated"); - } /* end if */ - else { - HDfree(pre); - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ - - return (jstring)str; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix */ + return (herr_t)status; +} /* end H5P_prp_compare_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_evict_on_close - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close - (JNIEnv *env, jclass clss, jlong fapl_id, jboolean evict_on_close) +static herr_t +H5P_prp_close_cb + (const char *name, size_t size, void *value) { - herr_t retVal = -1; - hbool_t evict_on_close_val; + jmethodID mid; + jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + jint status = -1; - if (evict_on_close == JNI_TRUE) - evict_on_close_val = TRUE; - else - evict_on_close_val = FALSE; + if (JVMPTR->AttachCurrentThread(JVMPAR, (void **)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_prp_close_cb: failed to attach current thread to JVM"); + } - retVal = H5Pset_evict_on_close((hid_t)fapl_id, (hbool_t)evict_on_close_val); - if (retVal < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close */ + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, close_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_evict_on_close - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close - (JNIEnv *env, jclass clss, jlong fapl_id) -{ - hbool_t evict_on_close_val = FALSE; - jboolean bval = JNI_FALSE; + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(Ljava/lang/String;J[B)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (H5Pget_evict_on_close((hid_t)fapl_id, (hbool_t *)&evict_on_close_val) < 0) { - h5libraryError(env); - } /* end if */ - else { - if (evict_on_close_val == TRUE) - bval = JNI_TRUE; - } /* end else */ + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - return bval; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close */ + status = CBENVPTR->CallIntMethod(CBENVONLY, close_callback, mid, str, size, value); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk_opts - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts - (JNIEnv *env, jclass clss, jlong dcpl_id, jint opts) -{ - herr_t retVal = -1; +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - retVal = H5Pset_chunk_opts((hid_t)dcpl_id, (unsigned)opts); - if (retVal < 0) - h5libraryError(env); -} /* end Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts */ + return (herr_t)status; +} /* end H5P_prp_close_cb */ -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk_opts - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts - (JNIEnv *env, jclass clss, jlong dcpl_id) +static herr_t +H5P_iterate_cb + (hid_t prop_id, const char *name, void *cb_data) { - unsigned opts = 0; - - if (H5Pget_chunk_opts((hid_t)dcpl_id, opts) < 0) - h5libraryError(env); + cb_wrapper *wrapper = (cb_wrapper *) cb_data; + jmethodID mid; + jobject visit_callback = wrapper->visit_callback; + jstring str; + jclass cls; + JNIEnv *cbenv = NULL; + void *op_data = (void *) wrapper->op_data; + jint status = -1; - return (jint)opts; -} /* end Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts */ + if (JVMPTR->AttachCurrentThread(JVMPAR, (void**)&cbenv, NULL) < 0) { + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(CBENVONLY, "H5P_iterate_cb: failed to attach current thread to JVM"); + } -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_dset_no_attrs_hint - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong dcpl_id, jboolean minimize) -{ - herr_t retVal = -1; - hbool_t minimize_val; + if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (minimize == JNI_TRUE) - minimize_val = TRUE; - else - minimize_val = FALSE; + if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/callbacks/H5P_iterate_t;)I"))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - retVal = H5Pset_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t)minimize_val); - if (retVal < 0) - h5libraryError(env); -} + if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name))) + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_dset_no_attrs_hint - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint -(JNIEnv *env, jclass clss, jlong dcpl_id) -{ - hbool_t minimize = FALSE; - jboolean bval = JNI_FALSE; + status = CBENVPTR->CallIntMethod(CBENVONLY, visit_callback, mid, prop_id, str, op_data); + CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE); - if (H5Pget_dset_no_attrs_hint((hid_t)dcpl_id, (hbool_t *)&minimize) < 0) { - h5libraryError(env); - } - else { - if (minimize == TRUE) - bval = JNI_TRUE; - } /* end else */ +done: + if (cbenv) + JVMPTR->DetachCurrentThread(JVMPAR); - return bval; -} + return status; +} /* end H5P_iterate_cb */ #ifdef __cplusplus } /* end extern "C" */ diff --git a/java/src/jni/h5pImp.h b/java/src/jni/h5pImp.h index 056c569..8318be4 100644 --- a/java/src/jni/h5pImp.h +++ b/java/src/jni/h5pImp.h @@ -11,12 +11,13 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include /* Header for class hdf_hdf5lib_H5_H5_H5P */ #ifndef _Included_hdf_hdf5lib_H5_H5P #define _Included_hdf_hdf5lib_H5_H5P +#include + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ @@ -32,15 +33,6 @@ Java_hdf_hdf5lib_H5__1H5Pcreate /* * Class: hdf_hdf5lib_H5 - * Method: H5Pclose - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 * Method: H5Pget_class * Signature: (J)J */ @@ -59,1571 +51,201 @@ Java_hdf_hdf5lib_H5__1H5Pcopy /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_userblock - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1userblock -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_userblock - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1userblock -(JNIEnv *, jclass, jlong, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sizes - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sizes -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sizes - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sizes -(JNIEnv *, jclass, jlong, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sym_k - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sym_1k -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sym_k - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sym_1k -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_istore_k - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1istore_1k -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_istore_k - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1istore_1k -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_layout - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1layout -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_layout + * Method: H5Pclose * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1layout +Java_hdf_hdf5lib_H5__1H5Pclose (JNIEnv *, jclass, jlong); /* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk - * Signature: (JI[B)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk -(JNIEnv *, jclass, jlong, jint, jbyteArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk - * Signature: (JI[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk -(JNIEnv *, jclass, jlong, jint, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_alignment - * Signature: (JJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alignment -(JNIEnv *, jclass, jlong, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_alignment - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alignment -(JNIEnv *, jclass, jlong, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_external - * Signature: (JLjava/lang/String;JJ)I + * TODO: H5Pencode */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1external -(JNIEnv *, jclass, jlong, jstring, jlong, jlong); /* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_external_count - * Signature: (J)I + * TODO: H5Pdecode */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external_1count -(JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_external - * Signature: (JIJ[Ljava/lang/String;[J)I + * Method: _H5Pcreate_class + * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1external -(JNIEnv *, jclass, jlong, jint, jlong, jobjectArray, jlongArray); +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class + (JNIEnv*, jclass, jlong, jstring, jobject, jobject, jobject, jobject, jobject, jobject); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fill_value - * Signature: (JJ[B)I + * Method: _H5Pcreate_class_nocb + * Signature: (JLjava/lang/String;)J */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1value -(JNIEnv *, jclass, jlong, jlong, jbyteArray); +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb + (JNIEnv*, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fill_value - * Signature: (JJ[B)I + * Method: H5Pregister2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1value -(JNIEnv *, jclass, jlong, jlong, jbyteArray); +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2 + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject, jobject); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_filter - * Signature: (JIIJ[I)I + * Method: H5Pregister2_nocb + * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1filter -(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pregister2_1nocb + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nfilters - * Signature: (J)I + * Method: H5Pinsert2 + * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nfilters -(JNIEnv *, jclass, jlong); +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2 + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter - * Signature: (JI[I[J[IJ[Ljava/lang/String;)I + * Method: H5Pinsert2_nocb + * Signature: (JLjava/lang/String;J[B)V */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb + (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_driver - * Signature: (J)J + * Method: H5Pset + * Signature: (JLjava/lang/String;I)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1driver -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_cache - * Signature: (JIJJD)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1cache -(JNIEnv *, jclass, jlong, jint, jlong, jlong, jdouble); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_cache - * Signature: (J[I[J[J[D)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1cache -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jlongArray, jdoubleArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_buffer - * Signature: (JJ[B[B)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer -(JNIEnv *, jclass, jlong, jlong, jbyteArray, jbyteArray); +Java_hdf_hdf5lib_H5_H5Pset +(JNIEnv *, jclass, jlong, jstring, jint); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_buffer - * Signature: (J[B[B)I + * Method: H5Pexist + * Signature: (JLjava/lang/String;)Z */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer -(JNIEnv *, jclass, jlong, jbyteArray, jbyteArray); +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pexist +(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_buffer_size - * Signature: (JJ)V + * Method: H5Pget_size + * Signature: (JLjava/lang/String;)J */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1buffer_1size -(JNIEnv *, jclass, jlong, jlong); +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1size +(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_buffer_size + * Method: H5Pget_nprops * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1buffer_1size -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_preserve - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1preserve -(JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_preserve - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1preserve +Java_hdf_hdf5lib_H5_H5Pget_1nprops (JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_deflate - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1deflate -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_gc_references - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1gc_1references -(JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_gc_references - * Signature: (J)Z + * Method: H5Pget_class_name + * Signature: (J)Ljava/lang/String; */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1gc_1references +JNIEXPORT jstring JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1class_1name (JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_btree_ratios - * Signature: (JDDD)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1btree_1ratios -(JNIEnv *, jclass, jlong, jdouble, jdouble, jdouble); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_btree_ratios - * Signature: (J[D[D[D)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1btree_1ratios -(JNIEnv *, jclass, jlong, jdoubleArray, jdoubleArray, jdoubleArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_small_data_block_size - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1small_1data_1block_1size -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_small_data_block_size + * Method: H5Pget_class_parent * Signature: (J)J */ JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1small_1data_1block_1size +Java_hdf_hdf5lib_H5_H5Pget_1class_1parent (JNIEnv *, jclass, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_alloc_time - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1alloc_1time -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_alloc_time - * Signature: (J[I)I + * Method: H5Pisa_class + * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1alloc_1time -(JNIEnv *, jclass, jlong, jintArray); +Java_hdf_hdf5lib_H5_H5Pisa_1class +(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fill_time - * Signature: (JI)I + * Method: H5Pget + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fill_1time -(JNIEnv *, jclass, jlong, jint); +Java_hdf_hdf5lib_H5_H5Pget +(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fill_time - * Signature: (J[I)I + * Method: H5Pequal + * Signature: (JJ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fill_1time -(JNIEnv *, jclass, jlong, jintArray); +Java_hdf_hdf5lib_H5_H5Pequal +(JNIEnv *, jclass, jlong, jlong); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pfill_value_defined - * Signature: (J[I)I + * Method: H5Piterate + * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pfill_1value_1defined -(JNIEnv *, jclass, jlong, jintArray); +Java_hdf_hdf5lib_H5_H5Piterate + (JNIEnv*, jclass, jlong, jintArray, jobject, jobject); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fletcher32 - * Signature: (J)I + * Method: H5Pcopy_prop + * Signature: (JJLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fletcher32 -(JNIEnv *, jclass, jlong); +Java_hdf_hdf5lib_H5_H5Pcopy_1prop +(JNIEnv *, jclass, jlong, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_edc_check - * Signature: (JI)I + * Method: H5Premove + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1edc_1check -(JNIEnv *, jclass, jlong, jint); +Java_hdf_hdf5lib_H5_H5Premove +(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pget_edc_check - * Signature: (J)I + * Method: H5Punregister + * Signature: (JLjava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1edc_1check -(JNIEnv *, jclass, jlong); +Java_hdf_hdf5lib_H5_H5Punregister +(JNIEnv *, jclass, jlong, jstring); /* * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shuffle + * Method: _H5Pclose_class * Signature: (J)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shuffle +Java_hdf_hdf5lib_H5__1H5Pclose_1class (JNIEnv *, jclass, jlong); -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_szip - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1szip -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_hyper_vector_size - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1hyper_1vector_1size -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_hyper_vector_size - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1hyper_1vector_1size -(JNIEnv *, jclass, jlong, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pall_filters_avail - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pall_1filters_1avail -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pmodify_filter - * Signature: (JIIJ[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pmodify_1filter -(JNIEnv *, jclass, jlong, jint, jint, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter_by_id - * Signature: (JI[I[J[IJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fclose_degree - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fclose_1degree -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fclose_degree - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fclose_1degree -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_family - * Signature: (JJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1family -(JNIEnv *, jclass, jlong, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_family - * Signature: (J[J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1family -(JNIEnv *, jclass, jlong, jlongArray, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_core - * Signature: (JJZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1core -(JNIEnv *, jclass, jlong, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_core - * Signature: (J[J[Z)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1core -(JNIEnv *, jclass, jlong, jlongArray, jbooleanArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_family_offset - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1family_1offset -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_family_offset - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1family_1offset -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_log - * Signature: (JLjava/lang/String;JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log -(JNIEnv *, jclass, jlong, jstring, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Premove_filter - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5P1remove_1filter -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset - * Signature: (JLjava/lang/String;I)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pset -(JNIEnv *, jclass, jlong, jstring, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pexist - * Signature: (JLjava/lang/String;)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pexist -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_size - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1size -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nprops - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nprops -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_class_name - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1name -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_class_parent - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1class_1parent -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pisa_class - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pisa_1class -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pequal - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pequal -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pcopy_prop - * Signature: (JJLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pcopy_1prop -(JNIEnv *, jclass, jlong, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Premove - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Premove -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Punregister - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Punregister -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pclose_class - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5__1H5Pclose_1class -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter2 - * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter2 -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_filter_by_id2 - * Signature: (JI[I[J[IJ[Ljava/lang/String;[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1filter_1by_1id2 -(JNIEnv *, jclass, jlong, jint, jintArray, jlongArray, jintArray, jlong, jobjectArray, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_nlinks - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1nlinks -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_nlinks - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nlinks -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_libver_bounds - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1libver_1bounds -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_libver_bounds - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1libver_1bounds -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_link_creation_order - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1creation_1order -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_link_creation_order - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1creation_1order -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_attr_creation_order - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_attr_creation_order - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_copy_object - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1copy_1object -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_copy_object - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1copy_1object -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_create_intermediate_group - * Signature: (JZ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group -(JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_create_intermediate_group - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_data_transform - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1data_1transform -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_data_transform - * Signature: (J[Ljava/lang/String;J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1data_1transform -(JNIEnv *, jclass, jlong, jobjectArray, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_acc_flags - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_acc_flags - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_link_phase_change - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1link_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_link_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1link_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_attr_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_attr_phase_change - * Signature: (JII)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_phase_change - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1phase_1change -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_phase_change - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1phase_1change -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_nindexes - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1nindexes -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_nindexes - * Signature: (JI)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1nindexes -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_shared_mesg_index - * Signature: (JIII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1shared_1mesg_1index -(JNIEnv *, jclass, jlong, jint, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_shared_mesg_index - * Signature: (JI[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1shared_1mesg_1index -(JNIEnv *, jclass, jlong, jint, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_local_heap_size_hint - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1local_1heap_1size_1hint -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_local_heap_size_hint - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1local_1heap_1size_1hint -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_nbit - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1nbit -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_scaleoffset - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_est_link_info - * Signature: (JII)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1est_1link_1info -(JNIEnv *, jclass, jlong, jint, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_est_link_info - * Signature: (J[I)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1est_1link_1info -(JNIEnv *, jclass, jlong, jintArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_fapl - * Signature: (JJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pget_elink_fapl - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_prefix - * Signature: (JLjava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_prefix - * Signature: (J[Ljava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix -(JNIEnv *, jclass, jlong, jobjectArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_direct - * Signature: (JJJJ)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1direct -(JNIEnv *, jclass, jlong, jlong, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_direct - * Signature: (J[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1direct -(JNIEnv *, jclass, jlong, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_sec2 - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1sec2 -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_stdio - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1stdio -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_windows - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1windows -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_fapl_muti - * Signature: (J[I[J[Ljava/lang/String;[J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1fapl_1multi -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_muti - * Signature: (J[I[J[Ljava/lang/String;[JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi -(JNIEnv *, jclass, jlong, jintArray, jlongArray, jobjectArray, jlongArray, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_fapl_split - * Signature: (JLjava/lang/String;JLjava/lang/String;J)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split -(JNIEnv *, jclass, jlong, jstring, jlong, jstring, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_meta_block_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1meta_1block_1size -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_meta_block_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1meta_1block_1size -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_sieve_buf_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1sieve_1buf_1size -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_sieve_buf_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1sieve_1buf_1size -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_elink_file_cache_size - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1elink_1file_1cache_1size -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_elink_file_cache_size - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1elink_1file_1cache_1size -(JNIEnv *, jclass, jlong); - - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_mdc_config - * Signature: (J)Lhdf/hdf5lib/structs/H5AC_cache_config_t; - */ -JNIEXPORT jobject JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1config -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_mdc_config - * Signature: (JLhdf/hdf5lib/structs/H5AC_cache_config_t;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config -(JNIEnv *, jclass, jlong, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk_cache - * Signature: (JJJD)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1cache -(JNIEnv *, jclass, jlong, jlong, jlong, jdouble); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk_cache - * Signature: (J[J[J[D)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1cache -(JNIEnv *, jclass, jlong, jlongArray, jlongArray, jdoubleArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_obj_track_times - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_obj_track_times - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times -(JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_char_encoding - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_char_encoding - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual - * Signature: (JJLjava/lang/String;Ljava/lang/String;J)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual -(JNIEnv *, jclass, jlong, jlong, jstring, jstring, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_count - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1count -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_vspace - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1vspace -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_srcspace - * Signature: (JJ)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1srcspace -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_filename - * Signature: (JJ)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1filename -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_dsetname - * Signature: (JJ)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1dsetname -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_view - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1view -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_view - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1view -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_printf_gap - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1printf_1gap -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_printf_gap - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1printf_1gap -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy - * Signature: (J[Z[J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy -(JNIEnv *, jclass, jlong, jbooleanArray, jlongArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy_persist - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1persist -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_strategy_threshold - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1strategy_1threshold -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space_strategy - * Signature: (JIZJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1strategy -(JNIEnv *, jclass, jlong, jint, jboolean, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_file_space_page_size - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1file_1space_1page_1size -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_file_space_page_size - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1file_1space_1page_1size -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_mdc_log_options - * Signature: (JZLjava/lang/String;Z)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options -(JNIEnv *, jclass, jlong, jboolean, jstring, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_mdc_log_options - * Signature: (J[Z)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1mdc_1log_1options -(JNIEnv *, jclass, jlong, jbooleanArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_append_flush - * Signature: (JI[JLjava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1append_1flush - (JNIEnv*, jclass, jlong, jint, jlongArray, jobject, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pcreate_class_nocb - * Signature: (JLjava/lang/String;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb - (JNIEnv*, jclass, jlong, jstring); -/* - * Class: hdf_hdf5lib_H5 - * Method: _H5Pcreate_class - * Signature: (JLjava/lang/String;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5__1H5Pcreate_1class - (JNIEnv*, jclass, jlong, jstring, jobject, jobject, jobject, jobject, jobject, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pregister2_nocb - * Signature: (JLjava/lang/String;J[B)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2_1nocb - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pregister2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pregister2 - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pinsert2_nocb - * Signature: (JLjava/lang/String;J[B)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pinsert2 - * Signature: (JLjava/lang/String;J[BLjava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pinsert2 - (JNIEnv*, jclass, jlong, jstring, jlong, jbyteArray, jobject, jobject, jobject, jobject, jobject, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Piterate - * Signature: (J[ILjava/lang/Object;Ljava/lang/Object;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Piterate - (JNIEnv*, jclass, jlong, jintArray, jobject, jobject); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_metadata_read_attempts - * Signature: (J)J - */ -JNIEXPORT jlong JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1metadata_1read_1attempts -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_metadata_read_attempts - * Signature: (JJ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1metadata_1read_1attempts -(JNIEnv *, jclass, jlong, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_virtual_prefix - * Signature: (JLjava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_virtual_prefix - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1virtual_1prefix -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_efile_prefix - * Signature: (JLjava/lang/String;)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix -(JNIEnv *, jclass, jlong, jstring); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_efile_prefix - * Signature: (J)Ljava/lang/String; - */ -JNIEXPORT jstring JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1efile_1prefix -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_evict_on_close - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1evict_1on_1close -(JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_evict_on_close - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1evict_1on_1close -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_chunk_opts - * Signature: (JI)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1chunk_1opts -(JNIEnv *, jclass, jlong, jint); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_chunk_opts - * Signature: (J)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1chunk_1opts -(JNIEnv *, jclass, jlong); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pset_dset_no_attrs_hint - * Signature: (JZ)V - */ -JNIEXPORT void JNICALL -Java_hdf_hdf5lib_H5_H5Pset_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong, jboolean); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5Pget_dset_no_attrs_hint - * Signature: (J)Z - */ -JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5Pget_1dset_1no_1attrs_1hint - (JNIEnv *, jclass, jlong); - - #ifdef __cplusplus } /* end extern "C" */ #endif /* __cplusplus */ diff --git a/java/src/jni/h5pLAPLImp.c b/java/src/jni/h5pLAPLImp.c new file mode 100644 index 0000000..c4502d5 --- /dev/null +++ b/java/src/jni/h5pLAPLImp.c @@ -0,0 +1,237 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pLAPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nlinks + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nlinks + (JNIEnv *env, jclass clss, jlong lapl_id, jlong nlinks) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if (nlinks <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_nlinks: nlinks <= 0"); + + if ((retVal = H5Pset_nlinks((hid_t)lapl_id, (size_t)nlinks)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1nlinks */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nlinks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nlinks + (JNIEnv *env, jclass clss, jlong lapl_id) +{ + size_t nlinks = 0; + + UNUSED(clss); + + if (H5Pget_nlinks((hid_t)lapl_id, &nlinks) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong) nlinks; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1nlinks */ + +/* + * TODO: H5Pset_elink_cb + */ + +/* + * TODO: H5Pget_elink_cb + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_prefix + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix + (JNIEnv *env, jclass clss, jlong lapl_id, jstring prefix) +{ + const char *linkPrefix = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + PIN_JAVA_STRING(ENVONLY, prefix, linkPrefix, NULL, "H5Pset_elink_prefix: link prefix not pinned"); + + if ((retVal = H5Pset_elink_prefix((hid_t)lapl_id, linkPrefix)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (linkPrefix) + UNPIN_JAVA_STRING(ENVONLY, prefix, linkPrefix); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_prefix + * Signature: (J[Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix + (JNIEnv *env, jclass clss, jlong lapl_id, jobjectArray prefix) +{ + ssize_t prefix_size = -1; + size_t size = 0; + char *pre = NULL; + jstring str = NULL; + + UNUSED(clss); + + if (NULL == prefix) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_elink_prefix: prefix is NULL"); + + if ((prefix_size = H5Pget_elink_prefix((hid_t)lapl_id, (char *)NULL, size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (pre = (char *) HDmalloc(sizeof(char) * (size_t) prefix_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: memory allocation failed"); + + if (H5Pget_elink_prefix((hid_t)lapl_id, (char *)pre, (size_t) prefix_size + 1) < 0) + H5_LIBRARY_ERROR(ENVONLY); + pre[prefix_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, pre))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_JNI_FATAL_ERROR(ENVONLY, "H5Pget_elink_prefix: out of memory - unable to construct string from UTF characters"); + } + + ENVPTR->SetObjectArrayElement(ENVONLY, prefix, 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (pre) + HDfree(pre); + + return (jlong)prefix_size; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_fapl + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl + (JNIEnv *env, jclass clss, jlong lapl_id, jlong fapl_id) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_elink_fapl((hid_t)lapl_id, (hid_t)fapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pget_elink_fapl + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl + (JNIEnv *env, jclass clss, jlong lapl_id) +{ + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if ((retVal = H5Pget_elink_fapl((hid_t)lapl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jlong)retVal; +} /* end Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_acc_flags + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags + (JNIEnv *env, jclass clss, jlong lapl_id, jint flags) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_elink_acc_flags((hid_t)lapl_id, (unsigned)flags)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint) retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_acc_flags + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags + (JNIEnv *env, jclass clss, jlong lapl_id) +{ + unsigned flags; + + UNUSED(clss); + + if (H5Pget_elink_acc_flags((hid_t)lapl_id, &flags) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pLAPLImp.h b/java/src/jni/h5pLAPLImp.h new file mode 100644 index 0000000..8efcfb5 --- /dev/null +++ b/java/src/jni/h5pLAPLImp.h @@ -0,0 +1,107 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PLAPL +#define _Included_hdf_hdf5lib_H5_H5PLAPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_nlinks + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1nlinks +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_nlinks + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1nlinks +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Pset_elink_cb + */ + +/* + * TODO: H5Pget_elink_cb + */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_prefix + * Signature: (JLjava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix +(JNIEnv *, jclass, jlong, jstring); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_prefix + * Signature: (J[Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1prefix +(JNIEnv *, jclass, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_fapl + * Signature: (JJ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1fapl +(JNIEnv *, jclass, jlong, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: _H5Pget_elink_fapl + * Signature: (J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5__1H5Pget_1elink_1fapl +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_elink_acc_flags + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1elink_1acc_1flags +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_elink_acc_flags + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1elink_1acc_1flags +(JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PLAPL */ diff --git a/java/src/jni/h5pLCPLImp.c b/java/src/jni/h5pLCPLImp.c new file mode 100644 index 0000000..7c79796 --- /dev/null +++ b/java/src/jni/h5pLCPLImp.c @@ -0,0 +1,36 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pLCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pLCPLImp.h b/java/src/jni/h5pLCPLImp.h new file mode 100644 index 0000000..009d1b4 --- /dev/null +++ b/java/src/jni/h5pLCPLImp.h @@ -0,0 +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 * + * the 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PLCPL +#define _Included_hdf_hdf5lib_H5_H5PLCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PLCPL */ diff --git a/java/src/jni/h5pOCPLImp.c b/java/src/jni/h5pOCPLImp.c new file mode 100644 index 0000000..241842e --- /dev/null +++ b/java/src/jni/h5pOCPLImp.c @@ -0,0 +1,211 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pOCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_create_intermediate_group + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group + (JNIEnv *env, jclass clss, jlong lcpl_id, jboolean crt_intermed_group) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_create_intermediate_group((hid_t)lcpl_id, (unsigned)crt_intermed_group)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_create_intermediate_group + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group + (JNIEnv *env, jclass clss, jlong lcpl_id) +{ + unsigned crt_intermed_group = 0; + + UNUSED(clss); + + if (H5Pget_create_intermediate_group((hid_t)lcpl_id, &crt_intermed_group) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jboolean)crt_intermed_group; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_obj_track_times + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times + (JNIEnv *env, jclass clss, jlong objplid, jboolean track_times) +{ + hbool_t track = FALSE; + + UNUSED(clss); + + track = (JNI_TRUE == track_times) ? 1 : 0; + + if (H5Pset_obj_track_times((hid_t)objplid, track) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_obj_track_times + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times + (JNIEnv *env, jclass clss, jlong objplid) +{ + hbool_t track_times = FALSE; + jboolean retVal = JNI_FALSE; + + UNUSED(clss); + + if (H5Pget_obj_track_times((hid_t)objplid, &track_times) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + retVal = (track_times == TRUE) ? JNI_TRUE : JNI_FALSE; + +done: + return retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_phase_change + * Signature: (JII)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change + (JNIEnv *env, jclass clss, jlong ocpl_id, jint max_compact, jint min_dense) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_attr_phase_change((hid_t)ocpl_id, (unsigned)max_compact, (unsigned)min_dense)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change + (JNIEnv *env, jclass clss, jlong ocpl_id, jintArray attributes) +{ + jboolean isCopy; + jint *theArray = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (NULL == attributes) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_attr_phase_change: attributes is NULL"); + + PIN_INT_ARRAY(ENVONLY, attributes, theArray, &isCopy, "H5Pget_attr_phase_change: input not pinned"); + + if ((retVal = H5Pget_attr_phase_change((hid_t)ocpl_id, (unsigned *)&(theArray[0]), (unsigned *)&(theArray[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (theArray) + UNPIN_INT_ARRAY(ENVONLY, attributes, theArray, (retVal < 0) ? JNI_ABORT : 0); + + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order + (JNIEnv *env, jclass clss, jlong ocpl_id, jint crt_order_flags) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_attr_creation_order((hid_t)ocpl_id, (unsigned)crt_order_flags)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order + (JNIEnv *env, jclass clss, jlong ocpl_id) +{ + unsigned crt_order_flags = 0; + + UNUSED(clss); + + if (H5Pget_attr_creation_order((hid_t)ocpl_id, &crt_order_flags) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)crt_order_flags; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pOCPLImp.h b/java/src/jni/h5pOCPLImp.h new file mode 100644 index 0000000..fe01f06 --- /dev/null +++ b/java/src/jni/h5pOCPLImp.h @@ -0,0 +1,99 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5POCPL +#define _Included_hdf_hdf5lib_H5_H5POCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_create_intermediate_group + * Signature: (JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1create_1intermediate_1group +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_create_intermediate_group + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1create_1intermediate_1group +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_obj_track_times + * Signature: (JZ)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1obj_1track_1times +(JNIEnv *, jclass, jlong, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_obj_track_times + * Signature: (J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1obj_1track_1times +(JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_phase_change + * Signature: (JII)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1phase_1change +(JNIEnv *, jclass, jlong, jint, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_phase_change + * Signature: (J[I)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1phase_1change +(JNIEnv *, jclass, jlong, jintArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_attr_creation_order + * Signature: (JI)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1attr_1creation_1order +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_attr_creation_order + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1attr_1creation_1order +(JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5POCPL */ diff --git a/java/src/jni/h5pOCpyPLImp.c b/java/src/jni/h5pOCpyPLImp.c new file mode 100644 index 0000000..9481f91 --- /dev/null +++ b/java/src/jni/h5pOCpyPLImp.c @@ -0,0 +1,92 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pOCpyPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_copy_object + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1copy_1object + (JNIEnv *env, jclass clss, jlong ocp_plist_id, jint copy_options) +{ + herr_t retVal = FAIL; + + UNUSED(clss); + + if ((retVal = H5Pset_copy_object((hid_t)ocp_plist_id, (unsigned)copy_options)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1copy_1object */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_copy_object + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1copy_1object + (JNIEnv *env, jclass clss, jlong ocp_plist_id) +{ + unsigned copy_options = 0; + + UNUSED(clss); + + if (H5Pget_copy_object((hid_t)ocp_plist_id, ©_options) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)copy_options; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1copy_1object */ + +/* + * TODO: H5Padd_merge_committed_dtype_path + */ + +/* + * TODO: H5Pfree_merge_committed_dtype_paths + */ + +/* + * TODO: H5Pset_mcdt_search_cb + */ + +/* + * TODO: H5Pget_mcdt_search_cb + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pOCpyPLImp.h b/java/src/jni/h5pOCpyPLImp.h new file mode 100644 index 0000000..f1dca58 --- /dev/null +++ b/java/src/jni/h5pOCpyPLImp.h @@ -0,0 +1,61 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5POCpyPL +#define _Included_hdf_hdf5lib_H5_H5POCpyPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_copy_object + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1copy_1object +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_copy_object + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1copy_1object +(JNIEnv *, jclass, jlong); + +/* + * TODO: H5Padd_merge_committed_dtype_path + */ + +/* + * TODO: H5Pfree_merge_committed_dtype_paths + */ + +/* + * TODO: H5Pset_mcdt_search_cb + */ + +/* + * TODO: H5Pget_mcdt_search_cb + */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5POCpyPL */ diff --git a/java/src/jni/h5pStrCPLImp.c b/java/src/jni/h5pStrCPLImp.c new file mode 100644 index 0000000..e69847d --- /dev/null +++ b/java/src/jni/h5pStrCPLImp.c @@ -0,0 +1,74 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include +#include "hdf5.h" +#include "h5jni.h" +#include "h5pStrCPLImp.h" + +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_char_encoding + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding + (JNIEnv *env, jclass clss, jlong acpl, jint encoding) +{ + UNUSED(clss); + + if (H5Pset_char_encoding((hid_t)acpl, (H5T_cset_t)encoding) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; +} /* end Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_char_encoding + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding + (JNIEnv *env, jclass clss, jlong acpl) +{ + H5T_cset_t encoding = H5T_CSET_ERROR; + + UNUSED(clss); + + if (H5Pget_char_encoding((hid_t)acpl, &encoding) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return encoding; +} /* end Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding */ + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5pStrCPLImp.h b/java/src/jni/h5pStrCPLImp.h new file mode 100644 index 0000000..6e140d3 --- /dev/null +++ b/java/src/jni/h5pStrCPLImp.h @@ -0,0 +1,45 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by 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. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _Included_hdf_hdf5lib_H5_H5PStrCPL +#define _Included_hdf_hdf5lib_H5_H5PStrCPL + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pset_char_encoding + * Signature: (JI)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5Pset_1char_1encoding +(JNIEnv *, jclass, jlong, jint); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Pget_char_encoding + * Signature: (J)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Pget_1char_1encoding +(JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5PStrCPL */ diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c index d551120..4e096f1 100644 --- a/java/src/jni/h5plImp.c +++ b/java/src/jni/h5plImp.c @@ -26,7 +26,10 @@ extern "C" { #include "h5jni.h" #include "h5plImp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -37,9 +40,13 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLset_1loading_1state (JNIEnv *env, jclass clss, jint plugin_flags) { - if (H5PLset_loading_state((unsigned int)plugin_flags) < 0) { - h5libraryError(env); - } + UNUSED(clss); + + if (H5PLset_loading_state((unsigned int)plugin_flags) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5PLset_1loading_1state */ /* @@ -52,9 +59,13 @@ Java_hdf_hdf5lib_H5_H5PLget_1loading_1state (JNIEnv *env, jclass clss) { unsigned int plugin_type = 0; - if (H5PLget_loading_state(&plugin_type) < 0) { - h5libraryError(env); - } + + UNUSED(clss); + + if (H5PLget_loading_state(&plugin_type) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)plugin_type; } /* end Java_hdf_hdf5lib_H5_H5PLget_1loading_1state */ @@ -67,18 +78,19 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLappend (JNIEnv *env, jclass clss, jobjectArray plugin_path) { - const char *aName; - herr_t retVal = -1; + const char *newPath = NULL; + herr_t retVal = FAIL; - PIN_JAVA_STRING(plugin_path, aName); - if (aName != NULL) { - retVal = H5PLappend(aName); + UNUSED(clss); - UNPIN_JAVA_STRING(plugin_path, aName); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLappend: new path not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5PLappend(newPath)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (newPath) + UNPIN_JAVA_STRING(ENVONLY, plugin_path, newPath); } /* end Java_hdf_hdf5lib_H5_H5PLappend */ /* * Class: hdf_hdf5lib_H5 @@ -89,18 +101,19 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLprepend (JNIEnv *env, jclass clss, jobjectArray plugin_path) { - const char *aName; - herr_t retVal = -1; + const char *newPath = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); - PIN_JAVA_STRING(plugin_path, aName); - if (aName != NULL) { - retVal = H5PLprepend(aName); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLprepend: new path not pinned"); - UNPIN_JAVA_STRING(plugin_path, aName); + if ((retVal = H5PLprepend(newPath)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retVal < 0) - h5libraryError(env); - } +done: + if (newPath) + UNPIN_JAVA_STRING(ENVONLY, plugin_path, newPath); } /* end Java_hdf_hdf5lib_H5_H5PLprepend */ /* @@ -112,18 +125,22 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLreplace (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index) { - const char *aName; - herr_t retVal = -1; + const char *newPath = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); - PIN_JAVA_STRING(plugin_path, aName); - if (aName != NULL) { - retVal = H5PLreplace(aName, index); + if (index < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLreplace: index < 0"); - UNPIN_JAVA_STRING(plugin_path, aName); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLreplace: new path not pinned"); - if (retVal < 0) - h5libraryError(env); - } + if ((retVal = H5PLreplace(newPath, (unsigned) index)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (newPath) + UNPIN_JAVA_STRING(ENVONLY, plugin_path, newPath); } /* end Java_hdf_hdf5lib_H5_H5PLreplace */ /* @@ -135,18 +152,22 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLinsert (JNIEnv *env, jclass clss, jobjectArray plugin_path, jint index) { - const char *aName; - herr_t retVal = -1; + const char *newPath = NULL; + herr_t retVal = FAIL; + + UNUSED(clss); + + if (index < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLinsert: index < 0"); - PIN_JAVA_STRING(plugin_path, aName); - if (aName != NULL) { - retVal = H5PLinsert(aName, index); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLinsert: new path not pinned"); - UNPIN_JAVA_STRING(plugin_path, aName); + if ((retVal = H5PLinsert(newPath, (unsigned) index)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retVal < 0) - h5libraryError(env); - } +done: + if (newPath) + UNPIN_JAVA_STRING(ENVONLY, plugin_path, newPath); } /* end Java_hdf_hdf5lib_H5_H5PLinsert */ /* @@ -158,8 +179,16 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5PLremove (JNIEnv *env, jclass clss, jint index) { - if (H5PLremove(index) < 0) - h5libraryError(env); + UNUSED(clss); + + if (index < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLremove: index < 0"); + + if (H5PLremove((unsigned) index) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5PLremove */ /* @@ -171,33 +200,33 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5PLget (JNIEnv *env, jclass clss, jint index) { - char *aName; jstring str = NULL; ssize_t buf_size; + char *aName = NULL; + + UNUSED(clss); + + if (index < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLget: index < 0"); + + /* Get the length of the name */ + if ((buf_size = H5PLget((unsigned) index, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5PLget: failed to allocate plugin name buffer"); + + if ((H5PLget((unsigned) index, aName, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + aName[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (aName) + HDfree(aName); - /* get the length of the name */ - buf_size = H5PLget(index, NULL, 0); - - if (buf_size <= 0) { - h5badArgument(env, "H5PLget: buf_size <= 0"); - } /* end if */ - else { - buf_size++; /* add extra space for the null terminator */ - aName = (char*)HDmalloc(sizeof(char) * (size_t)buf_size); - if (aName == NULL) { - h5outOfMemory(env, "H5PLget: malloc failed"); - } /* end if */ - else { - buf_size = H5PLget(index, aName, (size_t)buf_size); - if (buf_size < 0) { - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - } - HDfree(aName); - } - } return str; } /* end Java_hdf_hdf5lib_H5_H5PLget */ @@ -211,9 +240,13 @@ Java_hdf_hdf5lib_H5_H5PLsize (JNIEnv *env, jclass clss) { unsigned int listsize = 0; - if (H5PLsize(&listsize) < 0) { - h5libraryError(env); - } + + UNUSED(clss); + + if (H5PLsize(&listsize) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)listsize; } /* end Java_hdf_hdf5lib_H5_H5PLsize */ diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index 5f2b86d..9278113 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -26,8 +26,10 @@ extern "C" { #include "h5jni.h" #include "h5rImp.h" -extern JavaVM *jvm; - +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -38,47 +40,42 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rcreate (JNIEnv *env, jclass clss, jbyteArray ref, jlong loc_id, jstring name, jint ref_type, jlong space_id) { - const char *rName; - herr_t status = -1; - jbyte *refP; - jboolean isCopy2; - - PIN_JAVA_STRING(name, rName); - if (rName != NULL) { - if (ref == NULL) { - h5nullArgument( env, "H5Rcreate: ref is NULL"); - } /* end if */ - else { - if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { - h5badArgument( env, "H5Rcreate: ref input array != H5R_OBJ_REF_BUF_SIZE"); - } /* end if */ - else if ((ref_type == H5R_DATASET_REGION) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { - h5badArgument( env, "H5Rcreate: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); - } /* end else if */ - else if ((ref_type != H5R_OBJECT) && (ref_type != H5R_DATASET_REGION)) { - h5badArgument( env, "H5Rcreate: ref_type unknown type "); - } /* end else if */ - else { - refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy2); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rcreate: ref not pinned"); - } /* end if */ - else { - status = H5Rcreate(refP, (hid_t)loc_id, rName, (H5R_type_t)ref_type, (hid_t)space_id); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - UNPIN_JAVA_STRING(name, rName); + const char *refName = NULL; + jboolean isCopy; + jbyte *refBuf = NULL; + jsize refBufLen; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference is NULL"); + + if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: ref array length < 0"); } + if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference input array length != H5R_OBJ_REF_BUF_SIZE") + else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: unknown reference type"); + + PIN_JAVA_STRING(ENVONLY, name, refName, NULL, "H5Rcreate: reference name not pinned"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rcreate: reference buffer not pinned"); + + if ((status = H5Rcreate(refBuf, (hid_t)loc_id, refName, (H5R_type_t)ref_type, (hid_t)space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (status < 0) ? JNI_ABORT : 0); + if (refName) + UNPIN_JAVA_STRING(ENVONLY, name, refName); + return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Rcreate */ @@ -91,33 +88,36 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rdereference (JNIEnv *env, jclass clss, jlong dataset, jlong access_list, jint ref_type, jbyteArray ref) { - jboolean isCopy; - jbyte *refP; - hid_t retVal = -1; - - if (ref == NULL) { - h5nullArgument( env, "H5Rdereference: ref is NULL"); - } /* end if */ - else if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { - h5badArgument( env, "H5Rdereference: obj ref input array != H5R_OBJ_REF_BUF_SIZE"); - } /* end else if */ - else if ((ref_type == H5R_DATASET_REGION) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { - h5badArgument( env, "H5Rdereference: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); - } /* end else if */ - else { - refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rderefernce: ref not pinned"); - } /* end if */ - else { - retVal = H5Rdereference2((hid_t)dataset, (hid_t)access_list, (H5R_type_t)ref_type, refP); - - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - - if (retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + jboolean isCopy; + jbyte *refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference buffer is NULL"); + + if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: ref array length < 0"); + } + + if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: reference input array length != H5R_OBJ_REF_BUF_SIZE") + else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rdereference: unknown reference type"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rderefernce: reference buffer not pinned"); + + if ((retVal = H5Rdereference2((hid_t)dataset, (hid_t)access_list, (H5R_type_t)ref_type, refBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Rdereference */ @@ -131,33 +131,34 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Rget_1region (JNIEnv *env, jclass clss, jlong dataset, jint ref_type, jbyteArray ref) { - hid_t retVal = -1; - jboolean isCopy; - jbyte *refP; - - if (ref_type != H5R_DATASET_REGION) { - h5badArgument( env, "H5Rget_region: bad ref_type "); - } /* end if */ - else if (ref == NULL) { - h5nullArgument( env, "H5Rget_region: ref is NULL"); - } /* end if */ - else if ( ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { - h5badArgument( env, "H5Rget_region: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); - } /* end if */ - else { - refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rget_region: ref not pinned"); - } /* end if */ - else { - retVal = H5Rget_region((hid_t)dataset, (H5R_type_t)ref_type, refP); - - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - - if (retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + jboolean isCopy; + jbyte *refBuf = NULL; + jsize refBufLen; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if (H5R_DATASET_REGION != ref_type) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_region: bad reference type"); + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_region: reference buffer is NULL"); + + if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_region: ref array length < 0"); + } + + if (refBufLen != H5R_DSET_REG_REF_BUF_SIZE) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_region: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_region: reference buffer not pinned"); + + if ((retVal = H5Rget_region((hid_t)dataset, (H5R_type_t)ref_type, refBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Rget_1region */ @@ -171,31 +172,27 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref) { - int retVal =-1; - jboolean isCopy; - jbyte *refP; - H5O_type_t object_info; - - - if (ref == NULL) { - h5nullArgument( env, "H5Rget_object_type: ref is NULL"); - } /* end if */ - else { - refP = (jbyte*)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rget_object_type: ref not pinned"); - } /* end if */ - else { - retVal = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refP, &object_info); - if(retVal >= 0) - retVal = object_info; - - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - - if (retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + H5O_type_t object_info; + jboolean isCopy; + jbyte *refBuf = NULL; + int retVal = -1; + + UNUSED(clss); + + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_obj_type: reference buffer is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_obj_type: reference buffer not pinned"); + + if ((retVal = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, &object_info)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (retVal >= 0) + retVal = object_info; + +done: + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, (retVal < 0) ? JNI_ABORT : 0); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1type */ @@ -209,46 +206,33 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jintArray ref_obj) { + jboolean isCopy, isCopy2; + jbyte *refBuf = NULL; + jint *ref_objP = NULL; + jint status; + int retVal = -1; + + UNUSED(clss); + + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_obj_type: reference buffer is NULL"); + if (NULL == ref_obj) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_obj_type: reference object is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_obj_type: reference buffer not pinned"); - jint status; - jboolean isCopy; - jbyte *refP; - jint *ref_objP; - int retVal = -1; - - - if (ref == NULL) { - h5nullArgument( env, "H5Rget_object_type: ref is NULL"); - } /* end if */ - else if (ref_obj == NULL) { - h5nullArgument( env, "H5Rget_object_type: ref_obj is NULL"); - } /* end else if */ - else { - refP = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rget_object_type: ref not pinned"); - } /* end if */ - else { - ref_objP = (jint *)ENVPTR->GetIntArrayElements(ENVPAR ref_obj, &isCopy); - if (ref_objP == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR ref,refP,0); - h5JNIFatalError(env, "H5Rget_object_type: ref_obj not pinned"); - } /* end if */ - else { - status = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refP, (H5O_type_t*)ref_objP); - retVal = ref_objP[0]; - - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR ref_obj,ref_objP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - ENVPTR->ReleaseIntArrayElements(ENVPAR ref_obj, ref_objP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + PIN_INT_ARRAY(ENVONLY, ref_obj, ref_objP, &isCopy2, "H5Rget_obj_type: reference object array not pinned"); + + if ((status = H5Rget_obj_type2((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, (H5O_type_t *)ref_objP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + retVal = ref_objP[0]; + +done: + if (ref_objP) + UNPIN_INT_ARRAY(ENVONLY, ref_obj, ref_objP, (status < 0) ? JNI_ABORT : 0); + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, JNI_ABORT); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Rget_1obj_1type2 */ @@ -262,57 +246,52 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Rget_1name (JNIEnv *env, jclass clss, jlong loc_id, jint ref_type, jbyteArray ref, jobjectArray name, jlong size) { - jlong ret_val = -1; - jbyte *refP; - jboolean isCopy; - char *aName = NULL; - jstring str; - size_t bs; - - bs = (size_t)size; - if (bs <= 0) { - h5badArgument(env, "H5Rget_name: size <= 0"); - } /* end if */ - else if (ref == NULL) { - h5nullArgument(env, "H5Rget_name: ref is NULL"); - } /* end else if */ - else { - if ((ref_type == H5R_OBJECT) && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_OBJ_REF_BUF_SIZE) { - h5badArgument(env, "H5Rget_name: obj ref input array != H5R_OBJ_REF_BUF_SIZE"); - } /* end if */ - else if ((ref_type == H5R_DATASET_REGION) - && ENVPTR->GetArrayLength(ENVPAR ref) != H5R_DSET_REG_REF_BUF_SIZE) { - h5badArgument(env, "H5Rget_name: region ref input array != H5R_DSET_REG_REF_BUF_SIZE"); - } /* end else if */ - else { - refP = (jbyte *)ENVPTR->GetByteArrayElements(ENVPAR ref, &isCopy); - if (refP == NULL) { - h5JNIFatalError(env, "H5Rget_name: ref not pinned"); - } /* end if */ - else { - aName = (char*)HDmalloc(sizeof(char)*bs); - if (aName == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - h5outOfMemory(env, "H5Rget_name: malloc failed"); - } /* end if */ - else { - ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refP, aName, bs) ; - - ENVPTR->ReleaseByteArrayElements(ENVPAR ref, refP, JNI_ABORT); - if (ret_val < 0) { - HDfree(aName); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR aName); - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, str); - - HDfree(aName); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + jstring str; + jsize refBufLen; + jbyte *refBuf = NULL; + char *aName = NULL; + jlong ret_val = -1; + + UNUSED(clss); + + if (size <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: size <= 0"); + if (NULL == ref) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference buffer is NULL"); + + if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: ref array length < 0"); + } + + if ((H5R_OBJECT == ref_type) && (refBufLen != H5R_OBJ_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: reference input array length != H5R_OBJ_REF_BUF_SIZE") + else if ((H5R_DATASET_REGION == ref_type) && (refBufLen != H5R_DSET_REG_REF_BUF_SIZE)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: region reference input array length != H5R_DSET_REG_REF_BUF_SIZE") + else if ((H5R_OBJECT != ref_type) && (H5R_DATASET_REGION != ref_type)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Rget_name: unknown reference type"); + + PIN_BYTE_ARRAY(ENVONLY, ref, refBuf, &isCopy, "H5Rget_name: reference buffer not pinned"); + + if (NULL == (aName = (char *) HDmalloc(sizeof(char) * (size_t)size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Rget_name: failed to allocate referenced object name buffer"); + + if ((ret_val = (jlong)H5Rget_name((hid_t)loc_id, (H5R_type_t)ref_type, refBuf, aName, (size_t)size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + aName[(size_t)size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, aName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, name, (jsize) 0, str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (aName) + HDfree(aName); + if (refBuf) + UNPIN_BYTE_ARRAY(ENVONLY, ref, refBuf, JNI_ABORT); return ret_val; } /* end Java_hdf_hdf5lib_H5_H5Rget_1name */ diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index 65cdd7b..67ea59d 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -26,7 +26,10 @@ extern "C" { #include "h5jni.h" #include "h5sImp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -37,12 +40,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate (JNIEnv *env, jclass clss, jint type) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Screate((H5S_class_t) type); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Screate((H5S_class_t) type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Screate */ @@ -55,98 +60,83 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Screate_1simple (JNIEnv *env, jclass clss, jint rank, jlongArray dims, jlongArray maxdims) { - hid_t retVal = -1; - jlong *dimsP, *maxdimsP; - jboolean isCopy; - hsize_t *sa = NULL; - hsize_t *msa = NULL; - int i; - int drank, mrank; - hsize_t *lp; - jlong *jlp; - - if (rank < 0) { - h5badArgument(env, "H5Screate_simple: rank is invalid"); - } /* end if */ - else if (dims == NULL) { - h5nullArgument(env, "H5Screate_simple: dims is NULL"); - } /* end else if */ + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + hsize_t *lp = NULL; + jlong *dimsP = NULL, *maxdimsP = NULL; + jlong *jlp = NULL; + jsize drank, mrank; + int i; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if (rank < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: rank is invalid"); + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: dims is NULL"); + + if ((drank = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: dims array length < 0"); + } + + if (drank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: dims rank is invalid"); + + if (NULL != maxdims) { + if ((mrank = ENVPTR->GetArrayLength(ENVONLY, maxdims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: maxdims array length < 0"); + } + + if (mrank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Screate_simple: maxdims rank is invalid"); + } + + PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Screate_simple: dims not pinned"); + + if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate dims buffer") + + jlp = (jlong *) dimsP; + for (i = 0; i < rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + + if (NULL == maxdims) { + maxdimsP = NULL; + msa = (hsize_t *)maxdimsP; + } else { - drank = (int)ENVPTR->GetArrayLength(ENVPAR dims); - if (drank != rank) { - h5badArgument(env, "H5Screate_simple: dims rank is invalid"); - return -1; - } /* end if */ - if (maxdims != NULL) { - mrank = (int)ENVPTR->GetArrayLength(ENVPAR maxdims); - if (mrank != rank) { - h5badArgument(env, "H5Screate_simple: maxdims rank is invalid"); - return -1; - } /* end if */ - } /* end if */ - dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); - if (dimsP == NULL) { - h5JNIFatalError(env, "H5Screate_simple: dims not pinned"); - return -1; - } /* end if */ + PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Screate_simple: maxdims not pinned"); - sa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (sa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Screate_simple: dims not converted to hsize_t"); - return -1; - } /* end if */ + if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Screate_simple: failed to allocate maxdims buffer") - jlp = (jlong *) dimsP; - for (i = 0; i < rank; i++) { + jlp = (jlong *) maxdimsP; + for (i = 0; i < mrank; i++) { *lp = (hsize_t) *jlp; lp++; jlp++; } /* end for */ + } - if (maxdims == NULL) { - maxdimsP = NULL; - msa = (hsize_t *)maxdimsP; - } /* end if */ - else { - maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); - if (maxdimsP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - h5JNIFatalError(env, "H5Screate_simple: maxdims not pinned"); - return -1; - } /* end if */ - msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (msa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - HDfree(sa); - h5JNIFatalError(env, "H5Screate_simple: dims not converted to hsize_t"); - return -1; - } /* end if */ - jlp = (jlong *)maxdimsP; - for (i = 0; i < mrank; i++) { - *lp = (hsize_t)*jlp; - lp++; - jlp++; - } /* end for */ - } /* end else */ - - retVal = H5Screate_simple(rank, (const hsize_t *)sa, (const hsize_t *)msa); - - if (maxdimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - if (msa) - HDfree(msa); - } /* end if */ + if ((retVal = H5Screate_simple(rank, (const hsize_t *)sa, (const hsize_t *)msa)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - if (sa) - HDfree(sa); - - if (retVal < 0) - h5libraryError(env); - } /* end else */ +done: + if (msa) + HDfree(msa); + if (maxdimsP) + UNPIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, JNI_ABORT); + if (sa) + HDfree(sa); + if (dimsP) + UNPIN_LONG_ARRAY(ENVONLY, dims, dimsP, JNI_ABORT); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Screate_1simple */ @@ -160,12 +150,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Scopy (JNIEnv *env, jclass clss, jlong space_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Scopy(space_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Scopy(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Scopy */ @@ -185,41 +177,37 @@ Java_hdf_hdf5lib_H5__1H5Scopy */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements - (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jlongArray coord) + (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jlongArray coords) { - herr_t status = -1; - jint i; - jlong *P; - jboolean isCopy; - hssize_t *sa; - int rank; - - if (coord == NULL) { - h5nullArgument( env, "H5Sselect_elements: coord is NULL"); - return -1; - } /* end if */ + jboolean isCopy; + hssize_t *sa = NULL; + jlong *P = NULL; + jint i; + int rank; + herr_t status = FAIL; - P = ENVPTR->GetLongArrayElements(ENVPAR env,coord,&isCopy); - if (P == NULL) { - h5JNIFatalError(env, "H5Sselect_elements: coord not pinned"); - return -1; - } /* end if */ - sa = (hssize_t *)HDmalloc( (size_t)num_elems * 2 * sizeof(hssize_t)); - if (sa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR env,coord,P,JNI_ABORT); - h5JNIFatalError(env, "H5Sselect_elements: coord array not converted to hssize_t"); - return -1; - } /* end if */ - for (i= 0; i < (num_elsms * 2); i++) { + UNUSED(clss); + + if (NULL == coords) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coords is NULL"); + + PIN_LONG_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); + + if (NULL == (sa = (hssize_t *) HDmalloc( (size_t)num_elemn * 2 * sizeof(hssize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + + for (i = 0; i < (num_elemn * 2); i++) { sa[i] = P[i]; } /* end for */ - status = H5Sselect_elements (space_id, (H5S_seloper_t)op, num_elemn, (const hssize_t **)&sa); - ENVPTR->ReleaseLongArrayElements(ENVPAR env, coord, P, JNI_ABORT); - HDfree(sa); + if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, num_elemn, (const hssize_t **)&sa)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); +done: + if (sa) + HDfree(sa); + if (P) + UNPIN_LONG_ARRAY(ENVONLY, coords, P, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1elements */ @@ -232,49 +220,51 @@ Java_hdf_hdf5lib_H5_H5Sselect_1elements */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1elements - (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jbyteArray coord) + (JNIEnv *env, jclass clss, jlong space_id, jint op, jint num_elemn, jbyteArray coords) { - int ii; - hsize_t *lp = NULL; - hsize_t *llp; - jlong *jlp; - herr_t status = -1; - jbyte *P; - jboolean isCopy; - jsize size; - int nlongs; - - if (coord == NULL) { - h5nullArgument(env, "H5Sselect_elements: coord is NULL"); - } /* end if */ - else { - P = ENVPTR->GetByteArrayElements(ENVPAR coord, &isCopy); - if (P == NULL) { - h5JNIFatalError(env, "H5Sselect_elements: coord not pinned"); - } /* end if */ - else { - size = (int)ENVPTR->GetArrayLength(ENVPAR coord); - nlongs = (int)((size_t)size / sizeof(jlong)); - lp = (hsize_t *)HDmalloc((size_t)nlongs * sizeof(hsize_t)); - jlp = (jlong *) P; - llp = lp; - for (ii = 0; ii < nlongs; ii++) { - *lp = (hsize_t) *jlp; - lp++; - jlp++; - } /* end for */ - - status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp); - - ENVPTR->ReleaseByteArrayElements(ENVPAR coord, P, JNI_ABORT); - - if (llp) - HDfree(llp); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *lp = NULL; + hsize_t *llp = NULL; + jlong *jlp = NULL; + jbyte *P = NULL; + jsize size; + int ii; + int nlongs; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == coords) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coords is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, coords, P, &isCopy, "H5Sselect_elements: coords not pinned"); + + if ((size = ENVPTR->GetArrayLength(ENVONLY, coords)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_elements: coords array length < 0"); + } + + nlongs = (int)((size_t)size / sizeof(jlong)); + + if (NULL == (lp = (hsize_t *) HDmalloc((size_t)nlongs * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_elements: failed to allocate coordinate buffer"); + + jlp = (jlong *) P; + llp = lp; + for (ii = 0; ii < nlongs; ii++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; + } /* end for */ + + if ((status = H5Sselect_elements(space_id, (H5S_seloper_t)op, (size_t)num_elemn, (const hsize_t *)llp)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (llp) + HDfree(llp); + if (P) + UNPIN_BYTE_ARRAY(ENVONLY, coords, P, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1elements */ @@ -288,12 +278,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1all (JNIEnv *env, jclass clss, jlong space_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Sselect_all(space_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Sselect_all(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1all */ @@ -306,12 +298,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1none (JNIEnv *env, jclass clss, jlong space_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Sselect_none(space_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Sselect_none(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1none */ @@ -326,12 +320,14 @@ Java_hdf_hdf5lib_H5_H5Sselect_1valid { htri_t bval = JNI_FALSE; - bval = H5Sselect_valid(space_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + if ((bval = H5Sselect_valid(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1valid */ @@ -344,11 +340,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints (JNIEnv *env, jclass clss, jlong space_id) { - hssize_t retVal = H5Sget_simple_extent_npoints(space_id); + hssize_t retVal = -1; + + UNUSED(clss); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Sget_simple_extent_npoints(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1npoints */ @@ -361,11 +360,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints (JNIEnv *env, jclass clss, jlong space_id) { - hssize_t retVal = H5Sget_select_npoints(space_id); + hssize_t retVal = -1; + + UNUSED(clss); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Sget_select_npoints(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1npoints */ @@ -380,10 +382,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1type { int retVal = -1; - retVal = H5Sget_select_type(space_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if (H5S_SEL_ERROR == (retVal = H5Sget_select_type(space_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1type */ @@ -398,10 +402,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims { int retVal = -1; - retVal = H5Sget_simple_extent_ndims(space_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + + if ((retVal = H5Sget_simple_extent_ndims(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint) retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1ndims */ @@ -414,100 +420,78 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims (JNIEnv *env, jclass clss, jlong space_id, jlongArray dims, jlongArray maxdims) { - int status = -1; - jlong *dimsP, *maxdimsP; - jboolean isCopy; - hsize_t *sa; - hsize_t *msa; - int i; - int rank = -1; - int mrank; - - if (dims == NULL) { + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + jlong *dimsP = NULL, *maxdimsP = NULL; + int i; + int rank = -1; + int mrank; + int status = -1; + + UNUSED(clss); + + if (NULL == dims) { dimsP = NULL; sa = (hsize_t *) dimsP; - } /* end if */ + } else { - dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); - if (dimsP == NULL) { - h5JNIFatalError(env, "H5Pget_simple_extent_dims: dims not pinned"); - return -1; - } /* end if */ - rank = (int)ENVPTR->GetArrayLength(ENVPAR dims); - sa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (sa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_simple_extent_dims: dims not converted to hsize_t"); - return -1; - } /* end if */ - } /* end else */ - if (maxdims == NULL) { + PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sget_simple_extent_dims: dims not pinned"); + + if ((rank = (int)ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: dims array length < 0"); + } + + if (NULL == (sa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate dimension buffer"); + } + + if (NULL == maxdims) { maxdimsP = NULL; msa = (hsize_t *) maxdimsP; - } /* end if */ + } else { - maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); - if (maxdimsP == NULL) { - if (dimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - } /* end if */ - h5JNIFatalError(env, "H5Pget_simple_extent_dims: maxdims not pinned"); - return -1; - } /* end if */ - mrank = (int) ENVPTR->GetArrayLength(ENVPAR maxdims); + PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sget_simple_extent_dims: maxdims not pinned"); + + if ((mrank = (int) ENVPTR->GetArrayLength(ENVONLY, maxdims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims array length < 0"); + } + if (rank < 0) rank = mrank; - else if (mrank != rank) { - if (dimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - } /* end if */ - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); - return -1; - } /* end else if */ - msa = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (msa == NULL) { - if (dimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - } /* end if */ - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_simple_extent_dims: maxdims not converted to hsize_t"); - return -1; - } /* end if */ - } /* end else */ + else if (mrank != rank) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: maxdims rank not same as dims"); - status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa); + if (NULL == (msa = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_simple_extent_dims: failed to allocate maximum dimension buffer"); + } - if (status < 0) { - if (dimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - } /* end if */ - if (maxdimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - HDfree(msa); - } /* end if */ - h5libraryError(env); - return -1; - } /* end if */ + if ((status = H5Sget_simple_extent_dims(space_id, (hsize_t *)sa, (hsize_t *)msa)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (dimsP != NULL) { + if (NULL != dimsP) { for (i = 0; i < rank; i++) { dimsP[i] = (jlong)sa[i]; } /* end for */ - HDfree(sa); - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); - } /* end if */ - if (maxdimsP != NULL) { + } + + if (NULL != maxdimsP) { for (i = 0; i < rank; i++) { maxdimsP[i] = (jlong)msa[i]; } /* end for */ + } + +done: + if (msa) HDfree(msa); - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, 0); - } /* end if */ + if (maxdimsP) + UNPIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, (status < 0) ? JNI_ABORT : 0); + if (sa) + HDfree(sa); + if (dimsP) + UNPIN_LONG_ARRAY(ENVONLY, dims, dimsP, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1dims */ @@ -523,11 +507,15 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type { H5S_class_t retVal = H5S_NO_CLASS; + UNUSED(clss); + if (space_id < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Sget_simple_extent_type(space_id); + if (H5S_NO_CLASS == (retVal = H5Sget_simple_extent_type(space_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type */ @@ -540,87 +528,81 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple (JNIEnv *env, jclass clss, jlong space_id, jint rank, jlongArray dims, jlongArray maxdims) { - herr_t status = -1; - jlong *dimsP, *maxdimsP; - jboolean isCopy; - hsize_t *sa; - hsize_t *msa; - int i; - int drank, mrank; - hsize_t *lp; - jlong *jlp; - - if (dims == NULL) { - h5nullArgument(env, "H5Sset_simple_extent: dims is NULL"); - return -1; - } /* end if */ - drank = (int) ENVPTR->GetArrayLength(ENVPAR dims); - if (drank != rank) { - h5badArgument(env, "H5Screate_simple: dims rank is invalid"); - return -1; - } /* end if */ - if (maxdims != NULL) { - mrank = (int) ENVPTR->GetArrayLength(ENVPAR maxdims); - if (mrank != rank) { - h5badArgument(env, "H5Screate_simple: maxdims rank is invalid"); - return -1; - } /* end if */ - } /* end if */ - dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); - if (dimsP == NULL) { - h5JNIFatalError(env, "H5Pset_simple_extent: dims not pinned"); - return -1; - } /* end if */ - sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)); - if (sa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Sset_simple_extent: dims not converted to hsize_t"); - return -1; - } /* end if */ + jboolean isCopy; + hsize_t *sa = NULL; + hsize_t *msa = NULL; + hsize_t *lp = NULL; + jlong *dimsP = NULL, *maxdimsP = NULL; + jlong *jlp = NULL; + jsize drank, mrank; + int i; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sset_extent_simple: dims is NULL"); + + if ((drank = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sset_extent_simple: dims array length < 0"); + } + + if (drank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sset_extent_simple: dims rank is invalid"); + + if (NULL != maxdims) { + if ((mrank = ENVPTR->GetArrayLength(ENVONLY, maxdims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sset_extent_simple: maxdims array length < 0"); + } + + if (mrank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sset_extent_simple: maxdims rank is invalid"); + } + + PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Sset_extent_simple: dims not pinned"); + + if (NULL == (sa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate dimension buffer"); + jlp = (jlong *) dimsP; for (i = 0; i < rank; i++) { *lp = (hsize_t) *jlp; lp++; jlp++; } /* end for */ - if (maxdims == NULL) { + + if (NULL == maxdims) { maxdimsP = NULL; msa = (hsize_t *) maxdimsP; - } /* end if */ + } else { - maxdimsP = ENVPTR->GetLongArrayElements(ENVPAR maxdims, &isCopy); - if (maxdimsP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5JNIFatalError(env, "H5Pset_simple_extent: maxdims not pinned"); - return -1; - } /* end if */ - msa = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (msa == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); - HDfree(sa); - h5JNIFatalError(env, "H5Sset_simple_extent: maxdims not converted to hsize_t"); - return -1; - } /* end if */ + PIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, &isCopy, "H5Sset_extent_simple: maxdims not pinned"); + + if (NULL == (msa = lp = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sset_extent_simple: failed to allocate maximum dimension buffer"); + jlp = (jlong *) maxdimsP; for (i = 0; i < rank; i++) { *lp = (hsize_t) *jlp; lp++; jlp++; } /* end for */ - } /* end else */ + } - status = H5Sset_extent_simple(space_id, rank, (hsize_t *) sa, (hsize_t *) msa); + if ((status = H5Sset_extent_simple(space_id, rank, (hsize_t *) sa, (hsize_t *) msa)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - HDfree(sa); - if (maxdimsP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR maxdims, maxdimsP, JNI_ABORT); +done: + if (msa) HDfree(msa); - } /* end if */ - - if (status < 0) - h5libraryError(env); + if (maxdimsP) + UNPIN_LONG_ARRAY(ENVONLY, maxdims, maxdimsP, JNI_ABORT); + if (sa) + HDfree(sa); + if (dimsP) + UNPIN_LONG_ARRAY(ENVONLY, dims, dimsP, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sset_1extent_1simple */ @@ -636,12 +618,14 @@ Java_hdf_hdf5lib_H5_H5Sis_1simple { htri_t bval = JNI_FALSE; - bval = H5Sis_simple(space_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Sis_simple(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Sis_1simple */ @@ -654,49 +638,50 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Soffset_1simple (JNIEnv *env, jclass clss, jlong space_id, jbyteArray offset) { - herr_t status; - jbyte *P = NULL; jboolean isCopy; - hssize_t *sa; + hssize_t *sa = NULL; + hssize_t *lp = NULL; size_t rank; - size_t i; - hssize_t *lp; - jlong *jlp; - - if (offset != NULL) { - P = ENVPTR->GetByteArrayElements(ENVPAR offset, &isCopy); - if (P == NULL) { - h5JNIFatalError(env, "H5Soffset_simple: offset not pinned"); - return -1; - } /* end if */ - i = (size_t)ENVPTR->GetArrayLength(ENVPAR offset); - rank = i / sizeof(jlong); - sa = lp = (hssize_t *)HDmalloc((size_t)rank * sizeof(hssize_t)); - if (sa == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR offset, P, JNI_ABORT); - h5JNIFatalError(env, "H5Soffset_simple: offset not converted to hssize_t"); - return -1; - } /* end if */ + jsize i; + jbyte *P = NULL; + jlong *jlp = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL != offset) { + PIN_BYTE_ARRAY(ENVONLY, offset, P, &isCopy, "H5Soffset_simple: offset not pinned"); + + if ((i = ENVPTR->GetArrayLength(ENVONLY, offset)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Soffset_simple: offset array length < 0"); + } + + rank = (size_t) i / sizeof(jlong); + + if (NULL == (sa = lp = (hssize_t *) HDmalloc((size_t)rank * sizeof(hssize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Soffset_simple: failed to allocate offset buffer"); + jlp = (jlong *) P; - for (i = 0; i < rank; i++) { + for (i = 0; (size_t) i < rank; i++) { *lp = (hssize_t) *jlp; lp++; jlp++; } /* end for */ - } /* end if */ + } else { P = NULL; sa = (hssize_t *) P; - } /* end else */ + } - status = H5Soffset_simple(space_id, sa); - if (P != NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR offset, P, JNI_ABORT); - HDfree(sa); - } /* end if */ + if ((status = H5Soffset_simple(space_id, sa)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (status < 0) - h5libraryError(env); +done: + if (sa) + HDfree(sa); + if (P) + UNPIN_BYTE_ARRAY(ENVONLY, offset, P, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Soffset_1simple */ @@ -710,12 +695,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sextent_1copy (JNIEnv *env, jclass clss, jlong space_id, jlong src_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Sextent_copy(space_id, src_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Sextent_copy(space_id, src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sextent_1copy */ @@ -730,12 +717,14 @@ Java_hdf_hdf5lib_H5_H5Sextent_1equal { htri_t bval = JNI_FALSE; - bval = H5Sextent_equal(space_id, src_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Sextent_equal(space_id, src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Sextent_1equal */ @@ -748,12 +737,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sset_1extent_1none (JNIEnv *env, jclass clss, jlong space_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Sset_extent_none(space_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Sset_extent_none(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sset_1extent_1none */ @@ -766,162 +757,131 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab (JNIEnv *env, jclass clss, jlong space_id, jint op, jlongArray start, jlongArray stride, jlongArray count, jlongArray block) { - herr_t status = -1; - jlong *startP, *strideP, *countP, *blockP; - jboolean isCopy; - hsize_t *strt; - hsize_t *strd; - hsize_t *cnt; - hsize_t *blk; - int rank; - int i; - hsize_t *lp; - jlong *jlp; - - if (start == NULL) { - h5nullArgument(env, "H5Sselect_hyperslab: start is NULL"); + jboolean isCopy; + hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; + hsize_t *lp = NULL; + jlong *startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; + jlong *jlp = NULL; + jsize start_rank, stride_rank, count_rank, block_rank; + int i; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == start) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: start is NULL"); + if (NULL == count) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: count is NULL"); + + if ((start_rank = ENVPTR->GetArrayLength(ENVONLY, start)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: start array length < 0"); + } + if ((count_rank = ENVPTR->GetArrayLength(ENVONLY, count)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: count array length < 0"); + } + + if (start_rank != count_rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: count and start have different rank!"); + + PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sselect_hyperslab: start not pinned"); + + if (NULL == (strt = lp = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate start buffer"); + + jlp = (jlong *) startP; + for (i = 0; i < start_rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; } /* end if */ - else if (count == NULL) { - h5nullArgument(env, "H5Sselect_hyperslab: count is NULL"); + + PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sselect_hyperslab: count not pinned"); + + if (NULL == (cnt = lp = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate count buffer"); + + jlp = (jlong *) countP; + for (i = 0; i < count_rank; i++) { + *lp = (hsize_t) *jlp; + lp++; + jlp++; } /* end if */ + + if (NULL == stride) { + strideP = NULL; + strd = (hsize_t *) strideP; + } else { - rank = (int) ENVPTR->GetArrayLength(ENVPAR start); - if (rank != ENVPTR->GetArrayLength(ENVPAR count)) { - h5badArgument(env, "H5Sselect_hyperslab: count and start have different rank!"); - return -1; - } /* end if */ + if ((stride_rank = ENVPTR->GetArrayLength(ENVONLY, stride)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: stride array length < 0"); + } - startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); - if (startP == NULL) { - h5JNIFatalError(env, "H5Sselect_hyperslab: start not pinned"); - return -1; - } /* end if */ - strt = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (strt == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - h5JNIFatalError(env, "H5Sselect_hyperslab: start not converted to hsize_t"); - return -1; - } /* end if */ + if (stride_rank != start_rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: stride and start have different rank!"); - jlp = (jlong *) startP; - for (i = 0; i < rank; i++) { + PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sselect_hyperslab: stride not pinned"); + + if (NULL == (strd = lp = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate stride buffer"); + + jlp = (jlong *) strideP; + for (i = 0; i < stride_rank; i++) { *lp = (hsize_t) *jlp; lp++; jlp++; } /* end if */ + } - countP = ENVPTR->GetLongArrayElements(ENVPAR count, &isCopy); - if (countP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(strt); - h5JNIFatalError(env, "H5Sselect_hyperslab: count not pinned"); - return -1; - } /* end if */ - cnt = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (cnt == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - HDfree(strt); - h5JNIFatalError(env, "H5Sselect_hyperslab: count not converted to hsize_t"); - return -1; - } /* end if */ + if (NULL == block) { + blockP = NULL; + blk = (hsize_t *) blockP; + } + else { + if ((block_rank = ENVPTR->GetArrayLength(ENVONLY, block)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: block array length < 0"); + } - jlp = (jlong *) countP; - for (i = 0; i < rank; i++) { + if (block_rank != start_rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sselect_hyperslab: block and start have different rank!"); + + PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sselect_hyperslab: block not pinned"); + + if (NULL == (blk = lp = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sselect_hyperslab: failed to allocate block buffer"); + + jlp = (jlong *) blockP; + for (i = 0; i < block_rank; i++) { *lp = (hsize_t) *jlp; lp++; jlp++; - } /* end if */ - if (stride == NULL) { - strideP = NULL; - strd = (hsize_t *) strideP; - } /* end if */ - else { - strideP = ENVPTR->GetLongArrayElements(ENVPAR stride, &isCopy); - if (strideP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - h5badArgument(env, "H5Sselect_hyperslab: stride not pinned"); - return -1; - } /* end if */ - strd = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (strd == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - h5JNIFatalError(env, "H5Sselect_hyperslab: stride not converted to hsize_t"); - return -1; - } /* end if */ - jlp = (jlong *) strideP; - for (i = 0; i < rank; i++) { - *lp = (hsize_t) *jlp; - lp++; - jlp++; - } /* end if */ - } /* end if */ - if (block == NULL) { - blockP = NULL; - blk = (hsize_t *) blockP; - } /* end if */ - else { - blockP = ENVPTR->GetLongArrayElements(ENVPAR block, &isCopy); - if (blockP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - if (strd != NULL) - free(strd); - - h5JNIFatalError(env, "H5Sselect_hyperslab: block not pinned"); - return -1; - } /* end if */ - blk = lp = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (blk == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - if (strd != NULL) - free(strd); - - h5JNIFatalError(env, "H5Sget_simple_extent: block not converted to hsize_t"); - return -1; - } /* end if */ - jlp = (jlong *) blockP; - for (i = 0; i < rank; i++) { - *lp = (hsize_t) *jlp; - lp++; - jlp++; - } /* end for */ - } /* end else */ - - status = H5Sselect_hyperslab(space_id, (H5S_seloper_t) op, (const hsize_t *) strt, (const hsize_t *) strd, - (const hsize_t *) cnt, (const hsize_t *) blk); - - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - HDfree(strt); + } /* end for */ + } + + if ((status = H5Sselect_hyperslab(space_id, (H5S_seloper_t) op, (const hsize_t *) strt, (const hsize_t *) strd, + (const hsize_t *) cnt, (const hsize_t *) blk)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (blk) + HDfree(blk); + if (blockP) + UNPIN_LONG_ARRAY(ENVONLY, block, blockP, JNI_ABORT); + if (strd) + HDfree(strd); + if (strideP) + UNPIN_LONG_ARRAY(ENVONLY, stride, strideP, JNI_ABORT); + if (cnt) HDfree(cnt); - if (strideP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - HDfree(strd); - } /* end if */ - if (blockP != NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); - HDfree(blk); - } /* end if */ - - if (status < 0) - h5libraryError(env); - } /* end else */ + if (countP) + UNPIN_LONG_ARRAY(ENVONLY, count, countP, JNI_ABORT); + if (strt) + HDfree(strt); + if (startP) + UNPIN_LONG_ARRAY(ENVONLY, start, startP, JNI_ABORT); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sselect_1hyperslab */ @@ -935,12 +895,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Sclose (JNIEnv *env, jclass clss, jlong space_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Sclose(space_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Sclose(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Sclose */ @@ -955,10 +917,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks { hssize_t retVal = -1; - retVal = H5Sget_select_hyper_nblocks((hid_t) spaceid); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + + if ((retVal = H5Sget_select_hyper_nblocks((hid_t) spaceid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1nblocks */ @@ -973,10 +937,12 @@ Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints { hssize_t retVal = -1; - retVal = H5Sget_select_elem_npoints((hid_t) spaceid); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Sget_select_elem_npoints((hid_t) spaceid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1npoints */ @@ -989,58 +955,53 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist (JNIEnv *env, jclass clss, jlong spaceid, jlong startblock, jlong numblocks, jlongArray buf) { - herr_t status = -1; - jlong *bufP; - jboolean isCopy; - hsize_t *ba; - int i; - int rank; - hsize_t st; - hsize_t nb; - - st = (hsize_t) startblock; - nb = (hsize_t) numblocks; - - if (buf == NULL) { - h5nullArgument(env, "H5Sget_select_hyper_blocklist: buf is NULL"); - } /* end if */ - else { - rank = H5Sget_simple_extent_ndims(spaceid); - if (rank <= 0) - rank = 1; - if (ENVPTR->GetArrayLength(ENVPAR buf) < (numblocks * rank)) { - h5badArgument(env, "H5Sget_select_hyper_blocklist: buf input array too small"); - } /* end if */ - else { - bufP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); - if (bufP == NULL) { - h5JNIFatalError(env, "H5Sget_select_hyper_blocklist: buf not pinned"); - } /* end if */ - else { - ba = (hsize_t *) HDmalloc((size_t)nb * 2 * (size_t)rank * sizeof(hsize_t)); - if (ba == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); - h5JNIFatalError(env, "H5Screate-simple: buffer not converted to hsize_t"); - } /* end if */ - else { - status = H5Sget_select_hyper_blocklist((hid_t)spaceid, st, nb, (hsize_t *)ba); - - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); - free(ba); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < (numblocks * 2 * rank); i++) { - bufP[i] = (jlong)ba[i]; - } /* end for */ - free(ba); - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *ba = NULL; + size_t i, buf_size; + jlong *bufP = NULL; + jsize buflen; + int rank; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: buf is NULL"); + if (numblocks < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: numblocks < 0"); + + if ((rank = H5Sget_simple_extent_ndims(spaceid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (rank == 0) + rank = 1; + + if ((buflen = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: buf array length < 0"); + } + + if (buflen < (numblocks * rank)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: buffer input array too small"); + + PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_hyper_blocklist: buffer not pinned"); + + buf_size = (size_t) numblocks * (size_t) 2 * (size_t) rank * sizeof(hsize_t); + if (NULL == (ba = (hsize_t *) HDmalloc(buf_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_hyper_blocklist: failed to allocate block list buffer"); + + if ((status = H5Sget_select_hyper_blocklist((hid_t)spaceid, (hsize_t) startblock, (hsize_t) numblocks, (hsize_t *)ba)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (buf_size / sizeof(hsize_t)); i++) { + bufP[i] = (jlong) ba[i]; + } /* end for */ + +done: + if (ba) + HDfree(ba); + if (bufP) + UNPIN_LONG_ARRAY(ENVONLY, buf, bufP, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1hyper_1blocklist */ @@ -1054,53 +1015,49 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1elem_1pointlist (JNIEnv *env, jclass clss, jlong spaceid, jlong startpoint, jlong numpoints, jlongArray buf) { - herr_t status = -1; - jlong *bufP; - jboolean isCopy; - hsize_t *ba; - int i; - int rank; - - if (buf == NULL) { - h5nullArgument(env, "H5Sget_select_elem_pointlist: buf is NULL"); - } /* end if */ - else { - rank = H5Sget_simple_extent_ndims(spaceid); - if (rank <= 0) - rank = 1; - if (ENVPTR->GetArrayLength(ENVPAR buf) < (numpoints * rank)) { - h5badArgument(env, "H5Sget_select_elem_pointlist: buf input array too small"); - } /* end if */ - else { - bufP = ENVPTR->GetLongArrayElements(ENVPAR buf, &isCopy); - if (bufP == NULL) { - h5JNIFatalError(env, "H5Sget_select_elem_pointlist: buf not pinned"); - } /* end if */ - else { - ba = (hsize_t *)HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)); - if (ba == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_select_elem_pointlist: buf not converted to hsize_t"); - } /* end if */ - else { - status = H5Sget_select_elem_pointlist((hid_t) spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba); - - if (status < 0) { - HDfree(ba); - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < (numpoints * rank); i++) { - bufP[i] = (jlong)ba[i]; - } /* end for */ - HDfree(ba); - ENVPTR->ReleaseLongArrayElements(ENVPAR buf, bufP, 0); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *ba = NULL; + jlong *bufP = NULL; + jsize buflen; + int i, rank; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: buffer is NULL"); + + if ((rank = H5Sget_simple_extent_ndims(spaceid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (rank == 0) + rank = 1; + + if ((buflen = ENVPTR->GetArrayLength(ENVONLY, buf)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: buf array length < 0"); + } + + if (buflen < (numpoints * rank)) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: buffer input array too small"); + + PIN_LONG_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sget_select_elem_pointlist: buffer not pinned"); + + if (NULL == (ba = (hsize_t *) HDmalloc(((size_t)numpoints * (size_t)rank) * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_elem_pointlist: failed to allocate point list buffer"); + + if ((status = H5Sget_select_elem_pointlist((hid_t)spaceid, (hsize_t)startpoint, (hsize_t)numpoints, (hsize_t *)ba)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (numpoints * rank); i++) { + bufP[i] = (jlong) ba[i]; + } /* end for */ + +done: + if (ba) + HDfree(ba); + if (bufP) + UNPIN_LONG_ARRAY(ENVONLY, buf, bufP, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end if */ @@ -1114,70 +1071,53 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds (JNIEnv *env, jclass clss, jlong spaceid, jlongArray start, jlongArray end) { - herr_t status = -1; - jlong *startP, *endP; - jboolean isCopy; - hsize_t *strt; - hsize_t *en; - int rank; - int i; - - if (start == NULL) { - h5nullArgument(env, "H5Sget_select_bounds: start is NULL"); - } /* end if */ - else if (end == NULL) { - h5nullArgument(env, "H5Sget_select_bounds: end is NULL"); - } /* end else if */ - else { - startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); - if (startP == NULL) { - h5JNIFatalError(env, "H5Sget_select_bounds: start not pinned"); - return -1; - } /* end if */ - rank = (int) ENVPTR->GetArrayLength(ENVPAR start); - strt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (strt == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_select_bounds: start not converted to hsize_t"); - return -1; - } /* end if */ + jboolean isCopy; + hsize_t *strt = NULL; + hsize_t *en = NULL; + size_t i; + jlong *startP = NULL, *endP = NULL; + jsize rank; + herr_t status = FAIL; - endP = ENVPTR->GetLongArrayElements(ENVPAR end, &isCopy); - if (endP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - free(strt); - h5JNIFatalError(env, "H5Sget_select_bounds: end not pinned"); - return -1; - } /* end if */ - en = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (en == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(strt); - h5JNIFatalError(env, "H5Sget_simple_extent: dims not converted to hsize_t"); - return -1; - } /* end if */ + UNUSED(clss); - status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en); + if (NULL == start) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_bounds: start is NULL"); + if (NULL == end) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_bounds: end is NULL"); - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, JNI_ABORT); - HDfree(strt); - HDfree(en); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < rank; i++) { - startP[i] = (jlong)strt[i]; - endP[i] = (jlong)en[i]; - } /* end for */ - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR end, endP, 0); - HDfree(strt); - HDfree(en); - } /* end else */ - } /* end else */ + PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sget_select_bounds: start not pinned"); + + if ((rank = ENVPTR->GetArrayLength(ENVONLY, start)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_select_bounds: start array length < 0"); + } + + if (NULL == (strt = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate start buffer"); + + PIN_LONG_ARRAY(ENVONLY, end, endP, &isCopy, "H5Sget_select_bounds: end not pinned"); + + if (NULL == (en = (hsize_t *) HDmalloc((size_t)rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_select_bounds: failed to allocate end buffer"); + + if ((status = H5Sget_select_bounds((hid_t) spaceid, (hsize_t *) strt, (hsize_t *) en)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (size_t) rank; i++) { + startP[i] = (jlong) strt[i]; + endP[i] = (jlong) en[i]; + } /* end for */ + +done: + if (en) + HDfree(en); + if (endP) + UNPIN_LONG_ARRAY(ENVONLY, end, endP, (status < 0) ? JNI_ABORT : 0); + if (strt) + HDfree(strt); + if (startP) + UNPIN_LONG_ARRAY(ENVONLY, start, startP, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Sget_1select_1bounds */ @@ -1191,43 +1131,37 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_H5_H5Sencode (JNIEnv *env, jclass cls, jlong obj_id) { - herr_t status = -1; - unsigned char *bufPtr; - size_t buf_size = 0; - jbyteArray returnedArray = NULL; - - if (obj_id < 0) { - h5badArgument(env, "H5Sencode: invalid argument"); - } /* end if */ - else { - status = H5Sencode(obj_id, NULL, &buf_size); + unsigned char *bufPtr = NULL; + size_t buf_size = 0; + herr_t status = FAIL; + jbyteArray returnedArray = NULL; - if (status < 0) { - h5libraryError(env); - } /* end else if */ - else if (buf_size == 0) { - h5badArgument(env, "H5Sencode: buf_size = 0"); - } /* end if */ - else { - bufPtr = (unsigned char*)HDcalloc((size_t) 1, buf_size); - if (bufPtr == NULL) { - h5outOfMemory(env, "H5Sencode: calloc failed"); - } /* end if */ - else { - status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size); - - if (status < 0) { - HDfree(bufPtr); - h5libraryError(env); - } /* end if */ - else { - returnedArray = ENVPTR->NewByteArray(ENVPAR (jsize)buf_size); - ENVPTR->SetByteArrayRegion(ENVPAR returnedArray, 0, (jsize)buf_size, (jbyte*) bufPtr); - HDfree(bufPtr); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + UNUSED(cls); + + if (obj_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: invalid object ID"); + + if ((status = H5Sencode(obj_id, NULL, &buf_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (buf_size == 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sencode: buf_size = 0"); + + if (NULL == (bufPtr = (unsigned char *) HDcalloc((size_t) 1, buf_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sencode: failed to allocate encoding buffer"); + + if ((status = H5Sencode((hid_t) obj_id, bufPtr, &buf_size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (returnedArray = ENVPTR->NewByteArray(ENVONLY, (jsize) buf_size))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetByteArrayRegion(ENVONLY, returnedArray, 0, (jsize) buf_size, (jbyte *) bufPtr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (bufPtr) + HDfree(bufPtr); return returnedArray; } /* end Java_hdf_hdf5lib_H5_H5Sencode */ @@ -1241,27 +1175,23 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Sdecode (JNIEnv *env, jclass cls, jbyteArray buf) { - hid_t sid = -1; - jbyte *bufP; - jboolean isCopy; + jboolean isCopy; + jbyte *bufP = NULL; + hid_t sid = H5I_INVALID_HID; - if (buf == NULL) { - h5nullArgument(env, "H5Sdecode: buf is NULL"); - } /* end if */ - else { - bufP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (bufP == NULL) { - h5JNIFatalError( env, "H5Sdecode: buf not pinned"); - } /* end if */ - else { - sid = H5Sdecode(bufP); + UNUSED(cls); + + if (NULL == buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Sdecode: buffer is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Sdecode: buffer not pinned"); - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, bufP, JNI_ABORT); + if ((sid = H5Sdecode(bufP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (sid < 0) - h5libraryError(env); - } /* end else if */ - } /* end else if */ +done: + if (bufP) + UNPIN_BYTE_ARRAY(ENVONLY, buf, bufP, JNI_ABORT); return (jlong)sid; } /* end Java_hdf_hdf5lib_H5_H5Sdecode */ @@ -1277,12 +1207,14 @@ Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab { htri_t bval = JNI_FALSE; - bval = H5Sis_regular_hyperslab((hid_t)obj_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(cls); + if ((bval = H5Sis_regular_hyperslab((hid_t)obj_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Sis_1regular_1hyperslab */ @@ -1295,131 +1227,126 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab (JNIEnv *env, jclass clss, jlong space_id, jlongArray start, jlongArray stride, jlongArray count, jlongArray block) { - herr_t status; - jlong *startP, *strideP, *countP, *blockP; - jboolean isCopy; - hsize_t *strt; - hsize_t *strd; - hsize_t *cnt; - hsize_t *blk; - int rank; - int i; - - if (start == NULL) { - h5nullArgument(env, "H5Sget_regular_hyperslab: start is NULL"); - } /* end if */ - else if (count == NULL) { - h5nullArgument(env, "H5Sget_regular_hyperslab: count is NULL"); - } /* end else if */ + jboolean isCopy; + hsize_t *strt = NULL, *strd = NULL, *cnt = NULL, *blk = NULL; + jlong *startP = NULL, *strideP = NULL, *countP = NULL, *blockP = NULL; + jsize start_rank = -1, stride_rank = -1, count_rank = -1, block_rank = -1; + int i, rank = -1; + herr_t status = FAIL; + + UNUSED(clss); + + if (space_id < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: invalid dataspace ID"); + + if ((rank = H5Sget_simple_extent_ndims(space_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == start) { + startP = NULL; + strt = (hsize_t *) startP; + } else { - rank = (int) ENVPTR->GetArrayLength(ENVPAR start); - if (rank != ENVPTR->GetArrayLength(ENVPAR count)) { - h5badArgument(env, "H5Sget_regular_hyperslab: count and start have different rank!"); - return; - } /* end if */ + if ((start_rank = ENVPTR->GetArrayLength(ENVONLY, start)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: start array length < 0"); + } - startP = ENVPTR->GetLongArrayElements(ENVPAR start, &isCopy); - if (startP == NULL) { - h5JNIFatalError(env, "H5Sget_regular_hyperslab: start not pinned"); - return; - } /* end if */ - strt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (strt == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: start not converted to hsize_t"); - return; - } /* end if */ + if (start_rank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: start rank doesn't match dataspace rank!"); - countP = ENVPTR->GetLongArrayElements(ENVPAR count, &isCopy); - if (countP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(strt); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: count not pinned"); - return; - } /* end if */ - cnt = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (cnt == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - HDfree(strt); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: count not converted to hsize_t"); - return; - } /* end if */ + PIN_LONG_ARRAY(ENVONLY, start, startP, &isCopy, "H5Sget_regular_hyperslab: start not pinned"); - strideP = ENVPTR->GetLongArrayElements(ENVPAR stride, &isCopy); - if (strideP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - h5badArgument(env, "H5Sget_regular_hyperslab: stride not pinned"); - return; - } /* end if */ - strd = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (strd == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: stride not converted to hsize_t"); - return; - } /* end if */ + if (NULL == (strt = (hsize_t *) HDmalloc((size_t)start_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate start buffer"); + } - blockP = ENVPTR->GetLongArrayElements(ENVPAR block, &isCopy); - if (blockP == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - HDfree(strd); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: block not pinned"); - return; - } /* end if */ - blk = (hsize_t *)HDmalloc((size_t)rank * sizeof(hsize_t)); - if (blk == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); - HDfree(cnt); - HDfree(strt); - HDfree(strd); - h5JNIFatalError(env, "H5Sget_regular_hyperslab: block not converted to hsize_t"); - return; - } /* end if */ + if (NULL == stride) { + strideP = NULL; + strd = (hsize_t *) strideP; + } + else { + if ((stride_rank = ENVPTR->GetArrayLength(ENVONLY, stride)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: stride array length < 0"); + } - status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk); - - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, JNI_ABORT); - HDfree(strt); - HDfree(cnt); - HDfree(strd); - HDfree(blk); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < (rank); i++) { - startP[i] = (jlong)strt[i]; - countP[i] = (jlong)cnt[i]; - strideP[i] = (jlong)strd[i]; - blockP[i] = (jlong)blk[i]; - } /* end for */ - HDfree(strt); - HDfree(cnt); - HDfree(strd); - HDfree(blk); - ENVPTR->ReleaseLongArrayElements(ENVPAR start, startP, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR count, countP, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR stride, strideP, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR block, blockP, 0); - } /* end else */ - } /* end else */ + if (stride_rank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: stride rank doesn't match dataspace rank!"); + + PIN_LONG_ARRAY(ENVONLY, stride, strideP, &isCopy, "H5Sget_regular_hyperslab: stride not pinned"); + + if (NULL == (strd = (hsize_t *) HDmalloc((size_t)stride_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate stride buffer"); + } + + if (NULL == count) { + countP = NULL; + cnt = (hsize_t *) countP; + } + else { + if ((count_rank = ENVPTR->GetArrayLength(ENVONLY, count)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: count array length < 0"); + } + + if (count_rank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: count rank doesn't match dataspace rank!"); + + PIN_LONG_ARRAY(ENVONLY, count, countP, &isCopy, "H5Sget_regular_hyperslab: count not pinned"); + + if (NULL == (cnt = (hsize_t *) HDmalloc((size_t)count_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate count buffer"); + } + + if (NULL == block) { + blockP = NULL; + blk = (hsize_t *) blockP; + } + else { + if ((block_rank = ENVPTR->GetArrayLength(ENVONLY, block)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: block array length < 0"); + } + + if (block_rank != rank) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_regular_hyperslab: block rank doesn't match dataspace rank!"); + + PIN_LONG_ARRAY(ENVONLY, block, blockP, &isCopy, "H5Sget_regular_hyperslab: block not pinned"); + + if (NULL == (blk = (hsize_t *) HDmalloc((size_t)block_rank * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Sget_regular_hyperslab: failed to allocate block buffer"); + } + + if ((status = H5Sget_regular_hyperslab(space_id, (hsize_t *) strt, (hsize_t *) strd, (hsize_t *) cnt, (hsize_t *) blk)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < start_rank; i++) { + startP[i] = (jlong) strt[i]; + countP[i] = (jlong) cnt[i]; + strideP[i] = (jlong) strd[i]; + blockP[i] = (jlong) blk[i]; + } /* end for */ + +done: + if (blk) + HDfree(blk); + if (blockP) + UNPIN_LONG_ARRAY(ENVONLY, block, blockP, (status < 0) ? JNI_ABORT : 0); + if (cnt) + HDfree(cnt); + if (countP) + UNPIN_LONG_ARRAY(ENVONLY, count, countP, (status < 0) ? JNI_ABORT : 0); + if (strd) + HDfree(strd); + if (strideP) + UNPIN_LONG_ARRAY(ENVONLY, stride, strideP, (status < 0) ? JNI_ABORT : 0); + if (strt) + HDfree(strt); + if (startP) + UNPIN_LONG_ARRAY(ENVONLY, start, startP, (status < 0) ? JNI_ABORT : 0); + + return; } /* end Java_hdf_hdf5lib_H5_H5Sget_1regular_1hyperslab */ #ifdef __cplusplus diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 307f1a5..08ddf85 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -29,7 +29,10 @@ extern "C" { #include "h5jni.h" #include "h5tImp.h" -extern JavaVM *jvm; +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ +/* extern JavaVM *jvm; */ /* * Class: hdf_hdf5lib_H5 @@ -40,18 +43,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Topen2 (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong access_plist) { - hid_t status = -1; - const char *tName; + const char *datatypeName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(name, tName); - if (tName != NULL) { - status = H5Topen2((hid_t)loc_id, tName, (hid_t)access_plist); + UNUSED(clss); - UNPIN_JAVA_STRING(name, tName); + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Topen2: datatype name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Topen2((hid_t)loc_id, datatypeName, (hid_t)access_plist)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (datatypeName) + UNPIN_JAVA_STRING(ENVONLY, name, datatypeName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5__1H5Topen2 */ @@ -67,12 +71,14 @@ Java_hdf_hdf5lib_H5_H5Tcommitted { htri_t bval = JNI_FALSE; - bval = H5Tcommitted(type_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Tcommitted(type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Tcommitted */ @@ -85,12 +91,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcreate (JNIEnv *env, jclass clss, jint dclass, jlong size) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Tcreate((H5T_class_t )dclass, (size_t)size); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tcreate((H5T_class_t )dclass, (size_t)size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tcreate */ @@ -103,12 +111,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tcopy (JNIEnv *env, jclass clss, jlong type_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Tcopy((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tcopy((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tcopy */ @@ -123,12 +133,14 @@ Java_hdf_hdf5lib_H5_H5Tequal { htri_t bval = JNI_FALSE; - bval = H5Tequal((hid_t)type_id1, (hid_t)type_id2); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Tequal((hid_t)type_id1, (hid_t)type_id2)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Tequal */ @@ -141,12 +153,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tlock (JNIEnv *env, jclass clss, jlong type_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tlock((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tlock((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tlock */ @@ -161,10 +175,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1class { H5T_class_t retVal = H5T_NO_CLASS; - retVal = H5Tget_class((hid_t)type_id); - if (retVal == H5T_NO_CLASS) - h5libraryError(env); + UNUSED(clss); + if (H5T_NO_CLASS == (retVal = H5Tget_class((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1class */ @@ -179,10 +195,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1size { size_t retVal = 0; - retVal = H5Tget_size((hid_t)type_id); - if (retVal == 0) - h5libraryError(env); + UNUSED(clss); + + if (!(retVal = H5Tget_size((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1size*/ @@ -196,12 +214,14 @@ Java_hdf_hdf5lib_H5_H5Tset_1size (JNIEnv *env, jclass clss, jlong type_id, jlong size) { size_t tsize = (size_t)size; - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_size((hid_t)type_id, tsize); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_size((hid_t)type_id, tsize)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end ifJava_hdf_hdf5lib_H5_H5Tset_1size */ @@ -216,10 +236,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1order { H5T_order_t retVal = H5T_ORDER_ERROR; - retVal = H5Tget_order((hid_t)type_id); - if (retVal == H5T_ORDER_ERROR) - h5libraryError(env); + UNUSED(clss); + if (H5T_ORDER_ERROR == (retVal = H5Tget_order((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1order */ @@ -232,12 +254,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1order (JNIEnv *env, jclass clss, jlong type_id, jint order) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_order((hid_t)type_id, (H5T_order_t)order); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_order((hid_t)type_id, (H5T_order_t)order)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1order */ @@ -252,10 +276,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1precision { size_t retVal = 0; - retVal = H5Tget_precision((hid_t)type_id); - if (retVal == 0) - h5libraryError(env); + UNUSED(clss); + + if (!(retVal = H5Tget_precision((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1precision */ @@ -270,10 +296,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1precision_1long { size_t retVal = 0; - retVal = H5Tget_precision((hid_t)type_id); - if (retVal == 0) - h5libraryError(env); + UNUSED(clss); + if (!(retVal = H5Tget_precision((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1precision_1long */ @@ -286,12 +314,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1precision (JNIEnv *env, jclass clss, jlong type_id, jlong precision) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_precision((hid_t)type_id, (size_t)precision); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_precision((hid_t)type_id, (size_t)precision)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1precision */ @@ -306,10 +336,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1offset { int retVal = -1; - retVal = H5Tget_offset((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + + if ((retVal = H5Tget_offset((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1offset */ @@ -322,12 +354,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1offset (JNIEnv *env, jclass clss, jlong type_id, jlong offset) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Tset_offset((hid_t)type_id, (size_t)offset); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tset_offset((hid_t)type_id, (size_t)offset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1offset */ @@ -340,29 +374,23 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1pad (JNIEnv *env, jclass clss, jlong type_id, jintArray pad) { - herr_t status = -1; - jboolean isCopy; - jint *P; - - if (pad == NULL) { - h5nullArgument(env, "H5Tget_pad: pad is NULL"); - } /* end if */ - else { - P = ENVPTR->GetIntArrayElements(ENVPAR pad, &isCopy); - if (P == NULL) { - h5JNIFatalError(env, "H5Tget_pad: pad not pinned"); - } /* end if */ - else { - status = H5Tget_pad((hid_t)type_id, (H5T_pad_t *)&(P[0]), (H5T_pad_t *)&(P[1])); - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR pad, P, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR pad, P, 0); - } /* end else */ - } /* end else */ + jboolean isCopy; + jint *P = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == pad) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_pad: pad is NULL"); + + PIN_INT_ARRAY(ENVONLY, pad, P, &isCopy, "H5Tget_pad: pad not pinned"); + + if ((status = H5Tget_pad((hid_t)type_id, (H5T_pad_t *)&(P[0]), (H5T_pad_t *)&(P[1]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (P) + UNPIN_INT_ARRAY(ENVONLY, pad, P, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tget_1pad */ @@ -376,12 +404,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1pad (JNIEnv *env, jclass clss, jlong type_id, jint lsb, jint msb) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_pad((hid_t)type_id, (H5T_pad_t)lsb, (H5T_pad_t)msb); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_pad((hid_t)type_id, (H5T_pad_t)lsb, (H5T_pad_t)msb)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1pad */ @@ -396,10 +426,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1sign { H5T_sign_t retVal = H5T_SGN_ERROR; - retVal = H5Tget_sign((hid_t)type_id); - if (retVal == H5T_SGN_ERROR) - h5libraryError(env); + UNUSED(clss); + + if (H5T_SGN_ERROR == (retVal = H5Tget_sign((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1sign */ @@ -412,12 +444,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1sign (JNIEnv *env, jclass clss, jlong type_id, jint sign) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Tset_sign((hid_t)type_id, (H5T_sign_t)sign); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tset_sign((hid_t)type_id, (H5T_sign_t)sign)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1sign */ @@ -430,32 +464,31 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields_1int (JNIEnv *env, jclass clss, jlong type_id, jintArray fields) { - herr_t status; - jboolean isCopy; - jint *P; - - if (fields == NULL) { - h5nullArgument(env, "H5Tget_fields: fields is NULL"); - } /* end if */ - else if (ENVPTR->GetArrayLength(ENVPAR fields) < 5) { - h5badArgument(env, "H5Tget_fields: fields input array < order 5"); - } /* end else if */ - else { - P = ENVPTR->GetIntArrayElements(ENVPAR fields, &isCopy); - if (P == NULL) { - h5JNIFatalError(env, "H5Tget_fields: fields not pinned"); - } /* end if */ - else { - status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), (size_t *)&(P[3]), (size_t *)&(P[4])); - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR fields, P, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR fields, P, 0); - } /* end else */ - } /* end else */ + jboolean isCopy; + jsize arrLen; + jint *P = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == fields) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields_int: fields is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, fields)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields_int: fields array length < 0"); + } + if (arrLen < 5) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields_int: fields input array < order 5"); + + PIN_INT_ARRAY(ENVONLY, fields, P, &isCopy, "H5Tget_fields_int: fields not pinned"); + + if ((status = H5Tget_fields((hid_t)type_id, (size_t *)&(P[0]), (size_t *)&(P[1]), (size_t *)&(P[2]), (size_t *)&(P[3]), (size_t *)&(P[4]))) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (P) + UNPIN_INT_ARRAY(ENVONLY, fields, P, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tget_1fields_1int */ @@ -469,56 +502,57 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1fields (JNIEnv *env, jclass clss, jlong type_id, jlongArray fields) { - herr_t status; - jboolean isCopy; - jlong *fieldsArray; - - if (fields == NULL) { - h5nullArgument(env, "H5Tget_fields: fields is NULL"); - } /* end if */ - else if (ENVPTR->GetArrayLength(ENVPAR fields) < 5) { - h5badArgument(env, "H5Tget_fields: fields input array < order 5"); - } /* end else if */ - else { - fieldsArray = ENVPTR->GetLongArrayElements(ENVPAR fields, &isCopy); - if (fieldsArray == NULL) { - h5JNIFatalError(env, "H5Tget_fields: fields not pinned"); - } /* end if */ - else { - { /* direct cast (size_t *)variable fails on 32-bit environment */ - size_t spos_t = 0; - size_t epos_t = 0; - size_t esize_t = 0; - size_t mpos_t = 0; - size_t msize_t = 0; - long long fields_temp = *(&fieldsArray[0]); - spos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[1]); - epos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[2]); - esize_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[3]); - mpos_t = (size_t)fields_temp; - fields_temp = *(&fieldsArray[4]); - msize_t = (size_t)fields_temp; - - status = H5Tget_fields((hid_t)type_id, &spos_t, &epos_t, &esize_t, &mpos_t, &msize_t); - - *(&fieldsArray[0]) = (jlong)spos_t; - *(&fieldsArray[1]) = (jlong)epos_t; - *(&fieldsArray[2]) = (jlong)esize_t; - *(&fieldsArray[3]) = (jlong)mpos_t; - *(&fieldsArray[4]) = (jlong)msize_t; - } /* end direct cast special handling */ - - if (status < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR fields, fieldsArray, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseLongArrayElements(ENVPAR fields, fieldsArray, 0); - } /* end else */ - } /* end else */ + jboolean isCopy; + jlong *fieldsArray = NULL; + jsize arrLen; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == fields) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields: fields is NULL"); + + if ((arrLen = ENVPTR->GetArrayLength(ENVONLY, fields)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields: fields array length < 0"); + } + if (arrLen < 5) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_fields: fields input array < order 5"); + + PIN_LONG_ARRAY(ENVONLY, fields, fieldsArray, &isCopy, "H5Tget_fields: fields not pinned"); + + { /* Direct cast (size_t *)variable fails on 32-bit environment */ + size_t spos_t = 0; + size_t epos_t = 0; + size_t esize_t = 0; + size_t mpos_t = 0; + size_t msize_t = 0; + long long fields_temp = *(&fieldsArray[0]); + spos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[1]); + epos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[2]); + esize_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[3]); + mpos_t = (size_t)fields_temp; + fields_temp = *(&fieldsArray[4]); + msize_t = (size_t)fields_temp; + + if ((status = H5Tget_fields((hid_t)type_id, &spos_t, &epos_t, &esize_t, &mpos_t, &msize_t)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + *(&fieldsArray[0]) = (jlong)spos_t; + *(&fieldsArray[1]) = (jlong)epos_t; + *(&fieldsArray[2]) = (jlong)esize_t; + *(&fieldsArray[3]) = (jlong)mpos_t; + *(&fieldsArray[4]) = (jlong)msize_t; + } /* end direct cast special handling */ + +done: + if (fieldsArray) + UNPIN_LONG_ARRAY(ENVONLY, fields, fieldsArray, (status < 0) ? JNI_ABORT : 0); + + return; } /* end Java_hdf_hdf5lib_H5_H5Tget_1fields */ /* @@ -531,8 +565,13 @@ Java_hdf_hdf5lib_H5_H5Tset_1fields (JNIEnv *env, jclass clss, jlong type_id, jlong spos, jlong epos, jlong esize, jlong mpos, jlong msize) { + UNUSED(clss); + if (H5Tset_fields((hid_t)type_id, (size_t)spos, (size_t)epos, (size_t)esize, (size_t)mpos, (size_t)msize) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* end Java_hdf_hdf5lib_H5_H5Tset_1fields */ /* @@ -546,10 +585,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1ebias { size_t retVal = 0; - retVal = H5Tget_ebias((hid_t)type_id); - if (retVal == 0) - h5libraryError(env); + UNUSED(clss); + + if (!(retVal = H5Tget_ebias((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1ebias */ @@ -564,10 +605,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long { size_t retVal = 0; - retVal = H5Tget_ebias((hid_t)type_id); - if (retVal == 0) - h5libraryError(env); + UNUSED(clss); + if (!(retVal = H5Tget_ebias((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1ebias_1long */ @@ -580,12 +623,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1ebias (JNIEnv *env, jclass clss, jlong type_id, jlong ebias) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_ebias((hid_t)type_id, (size_t)ebias); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_ebias((hid_t)type_id, (size_t)ebias)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1ebias */ @@ -600,10 +645,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1norm { H5T_norm_t retVal = H5T_NORM_ERROR; - retVal = H5Tget_norm((hid_t)type_id); - if (retVal == H5T_NORM_ERROR) - h5libraryError(env); + UNUSED(clss); + + if (H5T_NORM_ERROR == (retVal = H5Tget_norm((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1norm */ @@ -616,12 +663,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1norm (JNIEnv *env, jclass clss, jlong type_id, jint norm) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Tset_norm((hid_t)type_id, (H5T_norm_t )norm); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tset_norm((hid_t)type_id, (H5T_norm_t )norm)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1norm */ @@ -636,10 +685,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1inpad { H5T_pad_t retVal = H5T_PAD_ERROR; - retVal = H5Tget_inpad((hid_t)type_id ); - if (retVal == H5T_PAD_ERROR) - h5libraryError(env); + UNUSED(clss); + + if (H5T_PAD_ERROR == (retVal = H5Tget_inpad((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1inpad */ @@ -652,12 +703,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1inpad (JNIEnv *env, jclass clss, jlong type_id, jint inpad) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_inpad((hid_t)type_id, (H5T_pad_t) inpad); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_inpad((hid_t)type_id, (H5T_pad_t) inpad)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1inpad */ @@ -672,10 +725,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1cset { H5T_cset_t retVal = H5T_CSET_ERROR; - retVal = H5Tget_cset((hid_t)type_id); - if (retVal == H5T_CSET_ERROR) - h5libraryError(env); + UNUSED(clss); + if (H5T_CSET_ERROR == (retVal = H5Tget_cset((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1cset */ @@ -688,12 +743,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1cset (JNIEnv *env, jclass clss, jlong type_id, jint cset) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tset_cset((hid_t)type_id, (H5T_cset_t)cset); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tset_cset((hid_t)type_id, (H5T_cset_t)cset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1cset */ @@ -708,10 +765,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1strpad { H5T_str_t retVal = H5T_STR_ERROR; - retVal = H5Tget_strpad((hid_t)type_id); - if (retVal == H5T_STR_ERROR) - h5libraryError(env); + UNUSED(clss); + + if (H5T_STR_ERROR == (retVal = H5Tget_strpad((hid_t)type_id))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1strpad */ @@ -724,12 +783,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1strpad (JNIEnv *env, jclass clss, jlong type_id, jint strpad) { - herr_t retVal = -1; + herr_t retVal = FAIL; - retVal = H5Tset_strpad((hid_t)type_id, (H5T_str_t)strpad); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tset_strpad((hid_t)type_id, (H5T_str_t)strpad)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tset_1strpad */ @@ -744,10 +805,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1nmembers { int retVal = -1; - retVal = H5Tget_nmembers((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + + if ((retVal = H5Tget_nmembers((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1nmembers */ @@ -760,17 +823,20 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1name (JNIEnv *env, jclass clss, jlong type_id, jint field_idx) { - char *name; - jstring str = NULL; + char *member_name = NULL; + jstring str = NULL; - name = H5Tget_member_name((hid_t)type_id, (unsigned)field_idx); - if (name != NULL) { - str = ENVPTR->NewStringUTF(ENVPAR name); - H5free_memory(name); + UNUSED(clss); - if (str == NULL) - h5JNIFatalError(env, "H5Tget_member_name: returned string not created"); - } /* end if */ + if (NULL == (member_name = H5Tget_member_name((hid_t)type_id, (unsigned)field_idx))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, member_name))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (member_name) + H5free_memory(member_name); return str; } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1name */ @@ -784,18 +850,19 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1index (JNIEnv *env, jclass clss, jlong type_id, jstring field_name) { - const char *tName; + const char *datatypeName = NULL; int index = -1; - PIN_JAVA_STRING(field_name, tName); - if (tName != NULL) { - index = H5Tget_member_index((hid_t)type_id, tName); + UNUSED(clss); - UNPIN_JAVA_STRING(field_name, tName); + PIN_JAVA_STRING(ENVONLY, field_name, datatypeName, NULL, "H5Tget_member_index: datatype name not pinned"); - if (index < 0) - h5libraryError(env); - } + if ((index = H5Tget_member_index((hid_t)type_id, datatypeName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (datatypeName) + UNPIN_JAVA_STRING(ENVONLY, field_name, datatypeName); return (jint)index; } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1index */ @@ -809,12 +876,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1member_1type (JNIEnv *env, jclass clss, jlong type_id, jint field_idx) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Tget_member_type((hid_t)type_id, (unsigned)field_idx); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tget_member_type((hid_t)type_id, (unsigned)field_idx)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tget_1member_1type */ @@ -827,6 +896,9 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1offset (JNIEnv *env, jclass clss, jlong type_id, jint memno) { + UNUSED(env); + UNUSED(clss); + return (jlong)H5Tget_member_offset((hid_t)type_id, (unsigned)memno); } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1offset */ @@ -839,12 +911,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1class (JNIEnv *env, jclass clss, jlong type_id, jint memno) { - int retVal = -1; + H5T_class_t retVal = H5T_NO_CLASS; + + UNUSED(clss); - retVal = H5Tget_member_class((hid_t)type_id, (unsigned)memno); - if (retVal < 0) - h5libraryError(env); + if (H5T_NO_CLASS == (retVal = H5Tget_member_class((hid_t)type_id, (unsigned)memno))) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1class */ @@ -857,18 +931,20 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tinsert (JNIEnv *env, jclass clss, jlong type_id, jstring name, jlong offset, jlong field_id) { - herr_t status = -1; - const char *tName; + const char *datatypeName = NULL; long off = (long)offset; + herr_t status = FAIL; - PIN_JAVA_STRING(name, tName); - if (tName != NULL) { - status = H5Tinsert((hid_t)type_id, tName, (size_t)off, field_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name,tName); - if (status < 0) - h5libraryError(env); - } + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Tinsert: datatype name not pinned"); + + if ((status = H5Tinsert((hid_t)type_id, datatypeName, (size_t)off, field_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (datatypeName) + UNPIN_JAVA_STRING(ENVONLY, name, datatypeName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tinsert */ @@ -882,12 +958,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tpack (JNIEnv *env, jclass clss, jlong type_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tpack((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tpack((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Tpack */ @@ -900,12 +978,14 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5__1H5Tclose (JNIEnv *env, jclass clss, jlong type_id) { - herr_t retVal = -1; + herr_t retVal = FAIL; + + UNUSED(clss); - retVal = H5Tclose((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tclose((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tclose */ @@ -918,12 +998,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tvlen_1create (JNIEnv *env, jclass clss, jlong base_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Tvlen_create((hid_t)base_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tvlen_create((hid_t)base_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tvlen_1create */ @@ -936,18 +1018,19 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tset_1tag (JNIEnv *env, jclass clss, jlong type, jstring tag) { - herr_t status = -1; - const char *tagP; + const char *tagBuf = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(tag, tagP); - if (tagP != NULL) { - status = H5Tset_tag((hid_t)type, tagP); + UNUSED(clss); - UNPIN_JAVA_STRING(tag,tagP); + PIN_JAVA_STRING(ENVONLY, tag, tagBuf, NULL, "H5Tset_tag: tag buffer not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Tset_tag((hid_t)type, tagBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (tagBuf) + UNPIN_JAVA_STRING(ENVONLY, tag, tagBuf); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tset_1tag */ @@ -961,17 +1044,20 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tget_1tag (JNIEnv *env, jclass clss, jlong type) { - jstring str = NULL; - char *tag; + jstring str = NULL; + char *tag = NULL; - tag = H5Tget_tag((hid_t)type); - if (tag != NULL) { - str = ENVPTR->NewStringUTF(ENVPAR tag); - H5free_memory(tag); + UNUSED(clss); + + if (NULL == (tag = H5Tget_tag((hid_t)type))) + H5_LIBRARY_ERROR(ENVONLY); - if (str == NULL) - h5JNIFatalError(env, "H5Tget_tag: returned string not created"); - } /* end if */ + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, tag))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (tag) + H5free_memory(tag); return str; } /* end Java_hdf_hdf5lib_H5_H5Tget_1tag */ @@ -985,12 +1071,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1super (JNIEnv *env, jclass clss, jlong type_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); - retVal = H5Tget_super((hid_t)type_id); - if (retVal < 0) - h5libraryError(env); + if ((retVal = H5Tget_super((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tget_1super */ @@ -1003,12 +1091,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tenum_1create (JNIEnv *env, jclass clss, jlong base_id) { - hid_t retVal = -1; + hid_t retVal = H5I_INVALID_HID; - retVal = H5Tenum_create((hid_t)base_id); - if (retVal < 0) - h5libraryError(env); + UNUSED(clss); + if ((retVal = H5Tenum_create((hid_t)base_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tenum_1create */ @@ -1021,32 +1111,28 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int (JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) { - herr_t status = -1; - jint *intP; - const char *nameP; - jboolean isCopy2; - - if (value == NULL ) { - h5nullArgument(env, "H5Tenum_insert: value is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, nameP); - if (nameP != NULL) { - intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy2); - if (intP == NULL) { - h5JNIFatalError(env, "H5Tenum_insert: value not pinned"); - } /* end if */ - else { - status = H5Tenum_insert((hid_t)type_id, nameP, intP); - - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); - - if (status < 0) - h5libraryError(env); - } /* end else */ - UNPIN_JAVA_STRING(name, nameP); - } - } /* end else */ + const char *memberName = NULL; + jboolean isCopy; + jint *intBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert: value is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, memberName, NULL, "H5Tenum_insert: member name not pinned"); + + PIN_INT_ARRAY(ENVONLY, value, intBuf, &isCopy, "H5Tenum_insert: int buffer not pinned"); + + if ((status = H5Tenum_insert((hid_t)type_id, memberName, intBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (intBuf) + UNPIN_INT_ARRAY(ENVONLY, value, intBuf, (status < 0) ? JNI_ABORT : 0); + if (memberName) + UNPIN_JAVA_STRING(ENVONLY, name, memberName); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int */ @@ -1060,32 +1146,28 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1insert (JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) { - herr_t status = -1; - jbyte *byteP; - const char *nameP; - jboolean isCopy2; - - if (value == NULL) { - h5nullArgument(env, "H5Tenum_insert: value is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, nameP); - if (nameP != NULL) { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy2); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Tenum_insert: value not pinned"); - } /* end if */ - else { - status = H5Tenum_insert((hid_t)type_id, nameP, byteP); - - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - - if (status < 0) - h5libraryError(env); - } /* end else */ - UNPIN_JAVA_STRING(name, nameP); - } - } /* end else */ + const char *memberName = NULL; + jboolean isCopy; + jbyte *memberBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert: value is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, memberName, NULL, "H5Tenum_insert: member name not pinned"); + + PIN_BYTE_ARRAY(ENVONLY, value, memberBuf, &isCopy, "H5Tenum_insert: member buffer not pinned"); + + if ((status = H5Tenum_insert((hid_t)type_id, memberName, memberBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (memberBuf) + UNPIN_BYTE_ARRAY(ENVONLY, value, memberBuf, (status < 0) ? JNI_ABORT : 0); + if (memberName) + UNPIN_JAVA_STRING(ENVONLY, name, memberName); } /* end Java_hdf_hdf5lib_H5_H5Tenum_1insert */ /* @@ -1098,51 +1180,39 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int (JNIEnv *env, jclass clss, jlong type_id, jintArray value, jobjectArray name, jint size) { - herr_t status = -1; - jint *intP; - char *nameP; - jboolean isCopy; - jstring str; - - if (size <= 0) { - h5badArgument(env, "H5Tenum_nameof: name size < 0"); - } /* end if */ - else if (value == NULL) { - h5nullArgument(env, "H5Tenum_nameof: value is NULL"); - } /* end if */ - else { - nameP = (char*)HDmalloc(sizeof(char) * (size_t)size); - if (nameP == NULL) { - /* exception -- out of memory */ - h5outOfMemory(env, "H5Tenum_nameof: malloc name size"); - } /* end if */ - else { - intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy); - if (intP == NULL) { - HDfree(nameP); - h5JNIFatalError(env, "H5Tenum_nameof: value not pinned"); - } /* end if */ - else { - status = H5Tenum_nameof((hid_t)type_id, intP, nameP, (size_t)size); - - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); - - if (status < 0) { - HDfree(nameP); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR nameP); - HDfree(nameP); - if (str == NULL) { - h5JNIFatalError(env, "H5Tenum_nameof: return array not created"); - } /* end if */ - else - ENVPTR->SetObjectArrayElement(ENVPAR name, 0, (jobject)str); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + jstring str; + jint *intP = NULL; + char *nameP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof_int: value is NULL"); + if (size <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof_int: name size < 0"); + + if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof_int: failed to allocate name buffer"); + + PIN_INT_ARRAY(ENVONLY, value, intP, &isCopy, "H5Tenum_nameof_int: value not pinned"); + + if ((status = H5Tenum_nameof((hid_t)type_id, intP, nameP, (size_t)size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nameP[(size_t)size - 1] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, nameP))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, name, 0, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (intP) + UNPIN_INT_ARRAY(ENVONLY, value, intP, JNI_ABORT); + if (nameP) + HDfree(nameP); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tenum_1nameof_1int */ @@ -1156,49 +1226,36 @@ JNIEXPORT jstring JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1nameof (JNIEnv *env, jclass clss, jlong type_id, jbyteArray value, jlong size) { - herr_t status = -1; - jbyte *byteP; - char *nameP; - jboolean isCopy; - jstring str = NULL; - - if (size <= 0) { - h5badArgument(env, "H5Tenum_nameof: name size < 0"); - } /* end if */ - else if (value == NULL ) { - h5nullArgument(env, "H5Tenum_nameof: value is NULL"); - } /* end if */ - else { - nameP = (char*)HDmalloc(sizeof(char) * (size_t)size); - if (nameP == NULL) { - h5outOfMemory(env, "H5Tenum_nameof: malloc name size"); - } /* end if */ - else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy); - if (byteP == NULL) { - HDfree(nameP); - h5JNIFatalError(env, "H5Tenum_nameof: value not pinned"); - } /* end if */ - else { - status = H5Tenum_nameof((hid_t)type_id, byteP, nameP, (size_t)size); - - /* free the buffer without copying back */ - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - - if (status < 0) { - HDfree(nameP); - h5libraryError(env); - } /* end if */ - else { - str = ENVPTR->NewStringUTF(ENVPAR nameP); - HDfree(nameP); - if (str == NULL) { - h5JNIFatalError(env, "H5Tenum_nameof: return array not created"); - } /* end if */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + jstring str = NULL; + jbyte *byteP = NULL; + char *nameP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); + if (size <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: name size < 0"); + + if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); + + PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Tenum_nameof: value not pinned"); + + if ((status = H5Tenum_nameof((hid_t)type_id, byteP, nameP, (size_t)size)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + nameP[(size_t)size - 1] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, nameP))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + +done: + if (byteP) + UNPIN_BYTE_ARRAY(ENVONLY, value, byteP, JNI_ABORT); + if (nameP) + HDfree(nameP); return str; } /* end Java_hdf_hdf5lib_H5_H5Tenum_1nameof */ @@ -1212,34 +1269,28 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int (JNIEnv *env, jclass clss, jlong type_id, jstring name, jintArray value) { - herr_t status = -1; - jint *intP; - const char *nameP; - jboolean isCopy2; - - if (value == NULL) { - h5nullArgument(env, "H5Tenum_valueof: value is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, nameP); - if (nameP != NULL) { - intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy2); - if (intP == NULL) { - h5JNIFatalError(env, "H5Tenum_valueof: value not pinned"); - } /* end if */ - else { - status = H5Tenum_valueof((hid_t)type_id, nameP, intP); - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, 0); - } /* end else */ - UNPIN_JAVA_STRING(name, nameP); - } - } /* end else */ + const char *enumValue = NULL; + jboolean isCopy; + jint *enumValueBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof_int: value is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, enumValue, NULL, "H5Tenum_valueof_int: enum value not pinned"); + + PIN_INT_ARRAY(ENVONLY, value, enumValueBuf, &isCopy, "H5Tenum_valueof_int: enum value buffer not pinned"); + + if ((status = H5Tenum_valueof((hid_t)type_id, enumValue, enumValueBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (enumValueBuf) + UNPIN_INT_ARRAY(ENVONLY, value, enumValueBuf, (status < 0) ? JNI_ABORT : 0); + if (enumValue) + UNPIN_JAVA_STRING(ENVONLY, name, enumValue); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int */ @@ -1253,34 +1304,28 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tenum_1valueof (JNIEnv *env, jclass clss, jlong type_id, jstring name, jbyteArray value) { - herr_t status = -1; - jbyte *byteP; - const char *nameP; - jboolean isCopy2; - - if (value == NULL) { - h5nullArgument(env, "H5Tenum_valueof: value is NULL"); - } /* end if */ - else { - PIN_JAVA_STRING(name, nameP); - if (nameP != NULL) { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value, &isCopy2); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Tenum_valueof: value not pinned"); - } /* end if */ - else { - status = H5Tenum_valueof((hid_t)type_id, nameP, byteP); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); - } /* end else */ - UNPIN_JAVA_STRING(name, nameP); - } - } /* end else */ + const char *enumValue = NULL; + jboolean isCopy; + jbyte *enumValueBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof: value is NULL"); + + PIN_JAVA_STRING(ENVONLY, name, enumValue, NULL, "H5Tenum_valueof: enum value not pinned"); + + PIN_BYTE_ARRAY(ENVONLY, value, enumValueBuf, &isCopy, "H5Tenum_valueof: enum value buffer not pinned"); + + if ((status = H5Tenum_valueof((hid_t)type_id, enumValue, enumValueBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (enumValueBuf) + UNPIN_BYTE_ARRAY(ENVONLY, value, enumValueBuf, (status < 0) ? JNI_ABORT : 0); + if (enumValue) + UNPIN_JAVA_STRING(ENVONLY, name, enumValue); } /* end Java_hdf_hdf5lib_H5_H5Tenum_1valueof */ /* @@ -1292,30 +1337,23 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int (JNIEnv *env, jclass clss, jlong type_id, jint membno, jintArray value) { - herr_t status = -1; - jint *intP; - jboolean isCopy; - - if (value == NULL) { - h5nullArgument(env, "H5Tget_member_value: value is NULL"); - } /* end if */ - else { - intP = ENVPTR->GetIntArrayElements(ENVPAR value, &isCopy); - if (intP == NULL) { - h5JNIFatalError(env, "H5Tget_member_value: value not pinned"); - } /* end if */ - else { - status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, intP); - - - if (status < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseIntArrayElements(ENVPAR value, intP, 0); - } /* end else */ - } /* end else */ + jboolean isCopy; + jint *intP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_member_value: value is NULL"); + + PIN_INT_ARRAY(ENVONLY, value, intP, &isCopy, "H5Tget_member_value: value not pinned"); + + if ((status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, intP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (intP) + UNPIN_INT_ARRAY(ENVONLY, value, intP, (status < 0) ? JNI_ABORT : 0); return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1value_1int */ @@ -1329,29 +1367,23 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tget_1member_1value (JNIEnv *env, jclass clss, jlong type_id, jint membno, jbyteArray value) { - herr_t status = -1; - jbyte *byteP; - jboolean isCopy; - - if (value == NULL) { - h5nullArgument( env, "H5Tget_member_value: value is NULL"); - } /* end if */ - else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR value,&isCopy); - if (byteP == NULL) { - h5JNIFatalError(env, "H5Tget_member_value: value not pinned"); - } /* end if */ - else { - status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, byteP); - - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else - ENVPTR->ReleaseByteArrayElements(ENVPAR value, byteP, 0); - } /* end else */ - } /* end else */ + jboolean isCopy; + jbyte *byteP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_member_value: value is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, value, byteP, &isCopy, "H5Tget_member_value: value not pinned"); + + if ((status = H5Tget_member_value((hid_t)type_id, (unsigned)membno, byteP)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (byteP) + UNPIN_BYTE_ARRAY(ENVONLY, value, byteP, (status < 0) ? JNI_ABORT : 0); } /* end Java_hdf_hdf5lib_H5_H5Tget_1member_1value */ /* @@ -1365,10 +1397,12 @@ Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims { int ndims = -1; - ndims = H5Tget_array_ndims((hid_t)type_id); - if (ndims < 0) - h5libraryError(env); + UNUSED(clss); + + if ((ndims = H5Tget_array_ndims((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)ndims; } /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1ndims */ @@ -1381,41 +1415,41 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims (JNIEnv *env, jclass clss, jlong type_id, jintArray dims, jintArray perms) { - int ndims = -1; - int dlen; - int i; - jint *dimsP; - hsize_t *cdims = NULL; - jboolean isCopy; - - if (dims == NULL) { - h5nullArgument( env, "H5Tget_array_dims: value is NULL"); - } /* end if */ - else { - dimsP = ENVPTR->GetIntArrayElements(ENVPAR dims, &isCopy); - if (dimsP == NULL) { - h5JNIFatalError(env, "H5Tget_array_dims: dimsP not pinned"); - } /* end if */ - else { - dlen = ENVPTR->GetArrayLength(ENVPAR dims); - cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); - - ndims = H5Tget_array_dims2((hid_t)type_id, cdims); - - if (ndims < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < dlen; i++) { - dimsP[i] = (jint) cdims[i]; - } /* end for */ - ENVPTR->ReleaseIntArrayElements(ENVPAR dims, dimsP, 0); - - if (cdims) HDfree(cdims); - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jsize dlen; + jint *dimsP = NULL; + int ndims = -1; + + UNUSED(clss); + UNUSED(perms); + + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_array_dims: dims array is NULL"); + + PIN_INT_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Tget_array_dims: dimsP not pinned"); + + if ((dlen = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tget_array_dims: dims array length < 0"); + } + + if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tget_array_dims: failed to allocate dimension buffer"); + + if ((ndims = H5Tget_array_dims2((hid_t)type_id, cdims)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (size_t) dlen; i++) { + dimsP[i] = (jint) cdims[i]; + } /* end for */ + +done: + if (cdims) + HDfree(cdims); + if (dimsP) + UNPIN_INT_ARRAY(ENVONLY, dims, dimsP, (ndims < 0) ? JNI_ABORT : 0); return (jint)ndims; } /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1dims */ @@ -1431,12 +1465,14 @@ Java_hdf_hdf5lib_H5_H5Tis_1variable_1str { htri_t bval = JNI_FALSE; - bval = H5Tis_variable_str((hid_t)type_id); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Tis_variable_str((hid_t)type_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Tis_1variable_1str */ @@ -1449,13 +1485,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tget_1native_1type (JNIEnv *env, jclass clss, jlong type_id, jint direction) { - hid_t native_tid = -1; + hid_t native_tid = H5I_INVALID_HID; - native_tid = H5Tget_native_type((hid_t)type_id, (H5T_direction_t)direction); + UNUSED(clss); - if (native_tid < 0) - h5libraryError(env); + if ((native_tid = H5Tget_native_type((hid_t)type_id, (H5T_direction_t)direction)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)native_tid; } /* end Java_hdf_hdf5lib_H5__1H5Tget_1native_1type */ @@ -1470,12 +1507,14 @@ Java_hdf_hdf5lib_H5_H5Tdetect_1class { htri_t bval = JNI_FALSE; - bval = H5Tdetect_class((hid_t)type_id, (H5T_class_t)dtype_class); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); + UNUSED(clss); + + if ((bval = H5Tdetect_class((hid_t)type_id, (H5T_class_t)dtype_class)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; +done: return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5Tdetect_1class */ @@ -1489,18 +1528,19 @@ Java_hdf_hdf5lib_H5_H5Tcommit (JNIEnv *env, jclass clss, jlong loc_id, jstring name, jlong type, jlong link_plist_id, jlong create_plist_id, jlong access_plist_id) { - herr_t status = -1; - const char *tName; + const char *datatypeName = NULL; + herr_t status = FAIL; - PIN_JAVA_STRING(name, tName); - if (tName != NULL) { - status = H5Tcommit2((hid_t)loc_id, tName, (hid_t)type, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id); + UNUSED(clss); - UNPIN_JAVA_STRING(name, tName); + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Tcommit: datatype name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5Tcommit2((hid_t)loc_id, datatypeName, (hid_t)type, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (datatypeName) + UNPIN_JAVA_STRING(ENVONLY, name, datatypeName); } /* end Java_hdf_hdf5lib_H5_H5Tcommit */ /* @@ -1512,45 +1552,45 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5__1H5Tarray_1create2 (JNIEnv *env, jclass clss, jlong base_id, jint rank, jlongArray dims) { - hid_t retVal = -1; - jlong *dimsP; - int dlen; - hsize_t *cdims = NULL; - jboolean isCopy; - int i; - - if (rank <= 0) { - h5badArgument(env, "H5Tarray_create: rank is < 1"); - } /* end if */ - else if (dims == NULL) { - h5nullArgument(env, "H5Tarray_create: dims is NULL"); - } /* end else if */ - else { - dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims, &isCopy); - if (dimsP == NULL) { - h5JNIFatalError( env, "H5Tarray_create: dimsP not pinned"); - } /* end if */ - else { - dlen = ENVPTR->GetArrayLength(ENVPAR dims); - if (dlen != rank) { - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - } /* end if */ - else { - cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); - for (i = 0; i < dlen; i++) { - cdims[i] = (hsize_t)dimsP[i]; - } /* end for */ - - retVal = H5Tarray_create2((hid_t)base_id, (unsigned)rank, (const hsize_t*)cdims); - - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); - - HDfree(cdims); - if (retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jlong *dimsP = NULL; + jsize dlen; + hid_t retVal = H5I_INVALID_HID; + + UNUSED(clss); + + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dims is NULL"); + if (rank <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: rank is < 1"); + + PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Tarray_create: dimsP not pinned"); + + if ((dlen = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dims array length < 0"); + } + + if (dlen != rank) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: dimension array length != array rank"); + + if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_create: failed to allocate dimension buffer"); + + for (i = 0; i < (size_t) dlen; i++) { + cdims[i] = (hsize_t)dimsP[i]; + } /* end for */ + + if ((retVal = H5Tarray_create2((hid_t)base_id, (unsigned)rank, (const hsize_t *)cdims)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (cdims) + HDfree(cdims); + if (dimsP) + UNPIN_LONG_ARRAY(ENVONLY, dims, dimsP, (retVal < 0) ? JNI_ABORT : 0); return (jlong)retVal; } /* end Java_hdf_hdf5lib_H5__1H5Tarray_1create2 */ @@ -1564,44 +1604,40 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 (JNIEnv *env, jclass clss, jlong type_id, jlongArray dims) { - int ndims = -1; - int dlen; - int i; - jlong *dimsP; - hsize_t *cdims=NULL; - jboolean isCopy; - - if (dims == NULL) { - h5nullArgument(env, "H5Tget_array_dims: value is NULL"); - } /* end if */ - else { - dimsP = ENVPTR->GetLongArrayElements(ENVPAR dims,&isCopy); - if (dimsP == NULL) { - h5JNIFatalError(env, "H5Tget_array_dims: dimsP not pinned"); - } /* end if */ - else { - dlen = ENVPTR->GetArrayLength(ENVPAR dims); - cdims = (hsize_t*)HDmalloc((size_t)dlen * sizeof(hsize_t)); - - ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims); - - if (ndims < 0) { - if (cdims) - free(cdims); - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, JNI_ABORT); - h5libraryError(env); - } /* end if */ - else { - for (i = 0; i < dlen; i++) { - dimsP[i] = (jlong) cdims[i]; - } /* end for */ - ENVPTR->ReleaseLongArrayElements(ENVPAR dims, dimsP, 0); - - if (cdims) - HDfree(cdims); - } /* end else */ - } /* end else */ - } /* end else */ + jboolean isCopy; + hsize_t *cdims = NULL; + size_t i; + jlong *dimsP = NULL; + jsize dlen; + int ndims = -1; + + UNUSED(clss); + + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tarray_get_dims2: value is NULL"); + + PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Tarray_get_dims2: dimsP not pinned"); + + if ((dlen = ENVPTR->GetArrayLength(ENVONLY, dims)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_get_dims2: dims array length < 0"); + } + + if (NULL == (cdims = (hsize_t *) HDmalloc((size_t)dlen * sizeof(hsize_t)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Tarray_get_dims2: failed to allocate dimension buffer"); + + if ((ndims = H5Tget_array_dims2((hid_t)type_id, (hsize_t*)cdims)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0; i < (size_t) dlen; i++) { + dimsP[i] = (jlong) cdims[i]; + } /* end for */ + +done: + if (cdims) + HDfree(cdims); + if (dimsP) + UNPIN_LONG_ARRAY(ENVONLY, dims, dimsP, (ndims < 0) ? JNI_ABORT : 0); return (jint)ndims; } /* end Java_hdf_hdf5lib_H5_H5Tget_1array_1dims2 */ @@ -1616,34 +1652,29 @@ Java_hdf_hdf5lib_H5_H5Tconvert (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id, jlong nelmts, jbyteArray buf, jbyteArray background, jlong plist_id) { - herr_t status; - jbyte *bufP; - jbyte *bgP = NULL; - jboolean isCopy; - - if (nelmts <= 0) { - h5badArgument(env, "H5Tconvert: name nelmts < 0"); - } /* end if */ - else { - bufP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (bufP == NULL) { - h5JNIFatalError(env, "H5Tconvert: value not pinned"); - } /* end if */ - else { - if (background) - bgP = ENVPTR->GetByteArrayElements(ENVPAR background, &isCopy); - - status = H5Tconvert((hid_t)src_id, (hid_t)dst_id, (size_t)nelmts, (void *)bufP, (void *)bgP, (hid_t)plist_id) ; - - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, bufP, 0); - - if (bgP) - ENVPTR->ReleaseByteArrayElements(ENVPAR background, bgP, 0); - - if (status < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ + jboolean isCopy; + jbyte *bufP = NULL; + jbyte *bgP = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + if (nelmts <= 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tconvert: nelmts < 0"); + + PIN_BYTE_ARRAY(ENVONLY, buf, bufP, &isCopy, "H5Tconvert: buffer not pinned"); + + if (background) + PIN_BYTE_ARRAY(ENVONLY, background, bgP, &isCopy, "H5Tconvert: background buffer not pinned"); + + if ((status = H5Tconvert((hid_t)src_id, (hid_t)dst_id, (size_t)nelmts, (void *)bufP, (void *)bgP, (hid_t)plist_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (bgP) + UNPIN_BYTE_ARRAY(ENVONLY, background, bgP, (status < 0) ? JNI_ABORT : 0); + if (bufP) + UNPIN_BYTE_ARRAY(ENVONLY, buf, bufP, (status < 0) ? JNI_ABORT : 0); } /* end Java_hdf_hdf5lib_H5_H5Tconvert */ /* @@ -1654,8 +1685,13 @@ Java_hdf_hdf5lib_H5_H5Tconvert JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Tflush(JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Tflush((hid_t)loc_id) < 0) - h5libraryError(env); + H5_LIBRARY_ERROR(ENVONLY); + +done: + return; } /* @@ -1666,10 +1702,14 @@ Java_hdf_hdf5lib_H5_H5Tflush(JNIEnv *env, jclass clss, jlong loc_id) JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5Trefresh(JNIEnv *env, jclass clss, jlong loc_id) { + UNUSED(clss); + if (H5Trefresh((hid_t)loc_id) < 0) - h5libraryError(env); -} + H5_LIBRARY_ERROR(ENVONLY); +done: + return; +} #ifdef __cplusplus diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index fd34ba1..4208ce1 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -32,7 +32,11 @@ extern "C" { hsize_t H5TOOLS_BUFSIZE = (32 * 1024 * 1024); /* 32 MB */ int H5TOOLS_TEXT_BLOCK = 16; /* Number of elements on a line in a text export file */ +/* + * Pointer to the JNI's Virtual Machine; used for callback functions. + */ JavaVM *jvm; + jobject copy_callback; jobject close_callback; jobject create_callback; @@ -41,22 +45,22 @@ jobject get_callback; jobject set_callback; jobject delete_callback; -H5E_auto2_t efunc; -void *edata; +H5E_auto2_t efunc; +void *edata; /********************/ /* Local Prototypes */ /********************/ -static int h5str_dump_region_blocks(h5str_t *str, hid_t region, hid_t region_obj); -static int h5str_dump_region_points(h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_dump_region_blocks(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); +static int h5str_dump_region_points(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); static int h5str_is_zero(const void *_mem, size_t size); static hid_t h5str_get_native_type(hid_t type); static hid_t h5str_get_little_endian_type(hid_t type); static hid_t h5str_get_big_endian_type(hid_t type); static htri_t h5str_detect_vlen(hid_t tid); static htri_t h5str_detect_vlen_str(hid_t tid); -static int h5tools_dump_simple_data(FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts); +static int h5tools_dump_simple_data(JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts); static int h5str_render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts); static int render_bin_output_region_data_blocks(FILE *stream, hid_t region_id, hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata); @@ -78,9 +82,10 @@ h5str_array_free return; for (i = 0; i < len; i++) { - if (*(strs + i)) - HDfree(*(strs + i)); + if (strs[i]) + HDfree(strs[i]); } /* for (i=0; imax == new_len) return; - new_str = (char *)HDmalloc(new_len); + if (NULL == (new_str = (char *) HDmalloc(new_len))) + return; + if (new_len > str->max) /* increase memory */ HDstrcpy(new_str, str->s); else @@ -152,860 +162,1044 @@ h5str_append return HDstrcat(str->s, cstr); } /* end h5str_append */ -/** print value of a vlen data point into string. - Return Value: - On success, the total number of characters printed is returned. - On error, a negative number is returned. +/* + * Converts the given data point string into a real data point. + * + * Returns: + * SUCCESS: Length of string token processed + * FAILURE: 0 */ size_t -h5str_vlconvert - (char *str, hid_t container, hid_t tid, hvl_t *ptr, int expand_data) +h5str_convert + (JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset) { - unsigned char tmp_uchar = 0; - char tmp_char = 0; - unsigned short tmp_ushort = 0; - short tmp_short = 0; - unsigned int tmp_uint = 0; - int tmp_int = 0; - unsigned long tmp_ulong = 0; - long tmp_long = 0; - unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; - float tmp_float = 0.0; - double tmp_double = 0.0; - long double tmp_ldouble = 0.0; - static char fmt_llong[8], fmt_ullong[8]; - - hid_t mtid = -1; - size_t offset; - size_t nll; - char *this_str; - size_t this_strlen; - int n; - H5T_class_t tclass = H5Tget_class(tid); - size_t size = H5Tget_size(tid); - H5T_sign_t nsign = H5Tget_sign(tid); - int bdata_print = 0; - - if (!str || !ptr) - return 0; - - this_str = NULL; - this_strlen = 0; + unsigned char *ucptr = NULL; + static char fmt_llong[8], fmt_ullong[8]; + H5T_class_t tclass = H5T_NO_CLASS; + const char delimiter[] = " ," H5_COMPOUND_BEGIN_INDICATOR H5_COMPOUND_END_INDICATOR \ + H5_ARRAY_BEGIN_INDICATOR H5_ARRAY_END_INDICATOR \ + H5_VLEN_BEGIN_INDICATOR H5_VLEN_END_INDICATOR; + size_t typeSize = 0; + hid_t mtid = H5I_INVALID_HID; + char *this_str = NULL; + char *token; + char *cptr = NULL; + int n; + size_t retVal = 0; + + if (!in_str) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_convert: in_str is NULL"); + if (!out_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_convert: out_buf is NULL"); + + this_str = *in_str; + cptr = &(((char *) out_buf)[out_buf_offset]); + ucptr = &(((unsigned char *) out_buf)[out_buf_offset]); + + if (H5T_NO_CLASS == (tclass = H5Tget_class(tid))) + H5_LIBRARY_ERROR(ENVONLY); + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + + /* Build default formats for long long types */ + if (!fmt_llong[0]) { + if (HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsprintf failure"); + if (HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: HDsprintf failure"); + } /* end if */ switch (tclass) { - case H5T_COMPOUND: + case H5T_FLOAT: { - unsigned i; - n = H5Tget_nmembers(tid); + token = HDstrtok(this_str, delimiter); - /* remove compound indicators */ - if (str[0] == ' ') - str++; - if (str[0] == '{') - str++; + switch (typeSize) { + case sizeof(float): + { + float tmp_float = 0.0; - ptr->p = HDcalloc((size_t)1, size); - ptr->len = size; - for (i = 0; i < n; i++) { - offset = H5Tget_member_offset(tid, i); - mtid = H5Tget_member_type(tid, i); - str += offset; - h5str_convert(&str, container, mtid, ptr, 0, expand_data); - /* remove compound indicators */ - if (str[0] == ',') - str++; - if (str[0] == ' ') - str++; - H5Tclose(mtid); + sscanf(token, "%f", &tmp_float); + HDmemcpy(cptr, &tmp_float, sizeof(float)); + break; + } + + case sizeof(double): + { + double tmp_double = 0.0; + + sscanf(token, "%lf", &tmp_double); + HDmemcpy(cptr, &tmp_double, sizeof(double)); + break; + } +#if H5_SIZEOF_LONG_DOUBLE != 0 + case sizeof(long double): + { + long double tmp_ldouble = 0.0; + + sscanf(token, "%Lf", &tmp_ldouble); + HDmemcpy(cptr, &tmp_ldouble, sizeof(long double)); + break; + } +#endif + + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: floating-point datatype size didn't match any of expected sizes"); + break; } - /* remove compound indicators */ - if (str[0] == '}') - str++; - if (str[0] == ' ') - str++; + + retVal = typeSize; + + break; } - break; - case H5T_ARRAY: + + case H5T_STRING: { - int rank = 0; - hsize_t i, dims[H5S_MAX_RANK], total_elmts; + size_t len = HDstrlen(this_str); - /* remove array indicators */ - if (str[0] == '[') - str++; - if (str[0] == ' ') - str++; + if (len > 0) { + HDstrncpy(cptr, this_str, typeSize); + retVal = typeSize; + } + else { + cptr = NULL; + } - mtid = H5Tget_super(tid); - size = H5Tget_size(mtid); - rank = H5Tget_array_ndims(tid); + break; + } - H5Tget_array_dims2(tid, dims); + case H5T_INTEGER: + { + H5T_sign_t nsign = H5T_SGN_ERROR; - total_elmts = 1; - for (i = 0; i < rank; i++) - total_elmts *= dims[i]; + if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid))) + H5_LIBRARY_ERROR(ENVONLY); - ptr->p = HDcalloc((size_t)total_elmts, size); - ptr->len = total_elmts; - h5str_convert(&str, container, mtid, ptr, 0, expand_data); - H5Tclose(mtid); - /* remove array indicators */ - if (str[0] == ' ') - str++; - if (str[0] == ']') - str++; - if (str[0] == ' ') - str++; - } - break; - default: - ptr->len = size; - ptr->p = HDcalloc(1, size); - this_strlen = h5str_convert(&str, container, tid, ptr, 0, expand_data); - break; - } /* end switch */ + token = HDstrtok(this_str, delimiter); - return this_strlen; -} /* end h5str_vlconvert */ + switch (typeSize) { + case sizeof(char): + { + unsigned char tmp_uchar = 0; + signed char tmp_char = 0; -/** print value of a data point into string. - Return Value: - On success, the total number of characters printed is returned. - On error, a negative number is returned. - */ -size_t -h5str_convert - (char **str, hid_t container, hid_t tid, hvl_t *ptr, int ptroffset, int expand_data) -{ - unsigned char tmp_uchar = 0; - char tmp_char = 0; - unsigned short tmp_ushort = 0; - short tmp_short = 0; - unsigned int tmp_uint = 0; - int tmp_int = 0; - unsigned long tmp_ulong = 0; - long tmp_long = 0; - unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; - float tmp_float = 0.0; - double tmp_double = 0.0; - long double tmp_ldouble = 0.0; - static char fmt_llong[8], fmt_ullong[8]; - const char delimiter[] = " ,}]"; - - char *token; - hid_t mtid = -1; - size_t offset; - size_t nll; - char *this_str = *str; - size_t this_strlen; - int n; - char *cptr = ((char*) ((hvl_t *) ptr)->p) + ptroffset; - unsigned char *ucptr = ((unsigned char*) ((hvl_t *) ptr)->p) + ptroffset; - H5T_class_t tclass = H5Tget_class(tid); - size_t size = H5Tget_size(tid); - H5T_sign_t nsign = H5Tget_sign(tid); - int bdata_print = 0; - - if (!str || !ptr) - return 0; + if (H5T_SGN_NONE == nsign) { + sscanf(token, "%hhu", &tmp_uchar); + HDmemcpy(cptr, &tmp_uchar, sizeof(unsigned char)); + } + else { + sscanf(token, "%hhd", &tmp_char); + HDmemcpy(cptr, &tmp_char, sizeof(char)); + } - /* Build default formats for long long types */ - if (!fmt_llong[0]) { - sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); - } /* end if */ + break; + } - this_strlen = HDstrlen(this_str); + case sizeof(short): + { + unsigned short tmp_ushort = 0; + short tmp_short = 0; - switch (tclass) { - case H5T_FLOAT: - token = HDstrtok (this_str, delimiter); - if (sizeof(float) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */ - tmp_float = 0; - sscanf(token, "%f", &tmp_float); - HDmemcpy(cptr, &tmp_float, sizeof(float)); - } - else if (sizeof(double) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */ - tmp_double = 0; - sscanf(token, "%%lf", &tmp_double); - HDmemcpy(cptr, &tmp_double, sizeof(double)); - } -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if (sizeof(long double) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */ - tmp_ldouble = 0; - sscanf(token, "%Lf", &tmp_ldouble); - HDmemcpy(cptr, &tmp_ldouble, sizeof(long double)); - } + if (H5T_SGN_NONE == nsign) { + sscanf(token, "%hu", &tmp_ushort); + HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); + } + else { + sscanf(token, "%hd", &tmp_short); + HDmemcpy(&tmp_short, cptr, sizeof(short)); + } + + break; + } + + case sizeof(int): + { + unsigned int tmp_uint = 0; + int tmp_int = 0; + + if (H5T_SGN_NONE == nsign) { + sscanf(token, "%u", &tmp_uint); + HDmemcpy(cptr, &tmp_uint, sizeof(unsigned int)); + } + else { + sscanf(token, "%d", &tmp_int); + HDmemcpy(cptr, &tmp_int, sizeof(int)); + } + + break; + } + + case sizeof(long): + { + unsigned long tmp_ulong = 0; + long tmp_long = 0; + + if (H5T_SGN_NONE == nsign) { + sscanf(token, "%lu", &tmp_ulong); + HDmemcpy(cptr, &tmp_ulong, sizeof(unsigned long)); + } + else { + sscanf(token, "%ld", &tmp_long); + HDmemcpy(cptr, &tmp_long, sizeof(long)); + } + + break; + } + +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG + case sizeof(long long): + { + unsigned long long tmp_ullong = 0; + long long tmp_llong = 0; + + if (H5T_SGN_NONE == nsign) { + sscanf(token, fmt_ullong, &tmp_ullong); + HDmemcpy(cptr, &tmp_ullong, sizeof(unsigned long long)); + } + else { + sscanf(token, fmt_llong, &tmp_llong); + HDmemcpy(cptr, &tmp_llong, sizeof(long long)); + } + + break; + } #endif - break; - case H5T_STRING: - { - if (this_strlen > 0) { - HDstrncpy(cptr, this_str, size); - } - else { - cptr = NULL; - } - } - break; - case H5T_INTEGER: - token = HDstrtok (this_str, delimiter); - if (sizeof(char) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */ - tmp_uchar = 0; - sscanf(token, "%hu", &tmp_uchar); - HDmemcpy(cptr, &tmp_uchar, sizeof(unsigned char)); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */ - tmp_char = 0; - sscanf(token, "%hd", &tmp_char); - HDmemcpy(cptr, &tmp_char, sizeof(char)); - } - } - else if (sizeof(int) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */ - tmp_uint = 0; - sscanf(token, "%u", &tmp_uint); - HDmemcpy(cptr, &tmp_uint, sizeof(unsigned int)); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_INT)) */ - tmp_int = 0; - sscanf(token, "%d", &tmp_int); - HDmemcpy(cptr, &tmp_int, sizeof(int)); - } - } - else if (sizeof(short) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */ - tmp_ushort = 0; - sscanf(token, "%u", &tmp_ushort); - HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */ - tmp_short = 0; - sscanf(token, "%d", &tmp_short); - HDmemcpy(&tmp_short, cptr, sizeof(short)); - } - } - else if (sizeof(long) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */ - tmp_ulong = 0; - sscanf(token, "%lu", &tmp_ulong); - HDmemcpy(cptr, &tmp_ulong, sizeof(unsigned long)); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */ - tmp_long = 0; - sscanf(token, "%ld", &tmp_long); - HDmemcpy(cptr, &tmp_long, sizeof(long)); + + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: integer datatype size didn't match any of expected sizes"); + break; } + + retVal = typeSize; + + break; } - else if (sizeof(long long) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */ - tmp_ullong = 0; - sscanf(token, fmt_ullong, &tmp_ullong); - HDmemcpy(cptr, &tmp_ullong, sizeof(unsigned long long)); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */ - tmp_llong = 0; - sscanf(token, fmt_llong, &tmp_llong); - HDmemcpy(cptr, &tmp_llong, sizeof(long long)); + + case H5T_COMPOUND: + { + unsigned i; + size_t member_offset; + + if ((n = H5Tget_nmembers(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* Skip whitespace and compound indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == '{') this_str++; + while (*this_str == ' ') this_str++; + + for (i = 0; i < (unsigned) n; i++) { + member_offset = H5Tget_member_offset(tid, i); + + if ((mtid = H5Tget_member_type(tid, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_convert(ENVONLY, &this_str, container, mtid, out_buf, member_offset)) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + goto done; + } + + /* Skip whitespace and commas */ + while (*this_str == ' ') this_str++; + if (*this_str == ',') this_str++; + while (*this_str == ' ') this_str++; + + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; } + + /* Skip whitespace and compound indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == '}') this_str++; + while (*this_str == ' ') this_str++; + + retVal = typeSize * (size_t) n; + + break; } - break; - case H5T_COMPOUND: - { - unsigned i; - n = H5Tget_nmembers(tid); - /* remove compound indicators */ - if ((*str)[0] == ' ') - (*str)++; - if ((*str)[0] == '{') - (*str)++; - - for (i = 0; i < n; i++) { - offset = H5Tget_member_offset(tid, i); - mtid = H5Tget_member_type(tid, i); - h5str_convert(str, container, mtid, ptr, offset, expand_data); - /* remove compound indicators */ - if ((*str)[0] == ',') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - H5Tclose(mtid); - } - /* remove compound indicators */ - if ((*str)[0] == '}') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - } - break; - case H5T_ENUM: - { - char enum_name[1024]; - void *value; - if (sizeof(char) == size) { - tmp_uchar = 0; - value = &tmp_uchar; - } - else if (sizeof(short) == size) { - tmp_ushort = 0; - value = &tmp_ushort; - } - else if (sizeof(long) == size) { - tmp_ulong = 0; - value = &tmp_ulong; - } - else if (sizeof(long long) == size) { - tmp_ullong = 0; - value = &tmp_ullong; - } - else { - tmp_uint = 0; - value = &tmp_uint; - } - token = HDstrtok (this_str, delimiter); - H5Tenum_valueof(tid, token, value); - HDmemcpy(ucptr, value, size); - } - break; - case H5T_REFERENCE: + /* TODO handle reference writing */ - cptr = NULL; - break; - case H5T_ARRAY: - { - int rank = 0; - hsize_t i, dims[H5S_MAX_RANK], total_elmts; - /* remove array indicators */ - if ((*str)[0] == '[') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - - mtid = H5Tget_super(tid); - offset = H5Tget_size(mtid); - rank = H5Tget_array_ndims(tid); - - H5Tget_array_dims2(tid, dims); - - total_elmts = 1; - for (i = 0; i < rank; i++) - total_elmts *= dims[i]; - - cptr = HDcalloc((size_t)total_elmts, offset); - for (i = 0; i < total_elmts; i++) { - h5str_convert(str, container, mtid, cptr + (i*offset), offset, expand_data); - /* remove array indicators */ - if ((*str)[0] == ',') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - } - H5Tclose(mtid); - /* remove array indicators */ - if ((*str)[0] == ' ') - (*str)++; - if ((*str)[0] == ']') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - } - break; - case H5T_VLEN: + case H5T_REFERENCE: + cptr = NULL; + break; + + case H5T_ENUM: { - unsigned int i; - mtid = H5Tget_super(tid); - offset = H5Tget_size(mtid); - - /* remove vlen indicators */ - if ((*str)[0] == '{') - (*str)++; - cptr = HDcalloc(offset, sizeof(hvl_t)); - for (i = 0; (i*offset) < (int)size; i++) { - h5str_convert(str, container, mtid, cptr + (i*offset), offset, expand_data); - /* remove vlen indicators */ - if ((*str)[0] == ',') - (*str)++; - if ((*str)[0] == ' ') - (*str)++; - if ((*str)[0] == '}') + void *value; + + token = HDstrtok(this_str, delimiter); + + switch (typeSize) { + case sizeof(char): + { + unsigned char tmp_uchar = 0; + value = &tmp_uchar; + break; + } + + case sizeof(short): + { + unsigned short tmp_ushort = 0; + value = &tmp_ushort; + break; + } + + case sizeof(long): + { + unsigned long tmp_ulong = 0; + value = &tmp_ulong; + break; + } + +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG + case sizeof(long long): + { + unsigned long long tmp_ullong = 0; + value = &tmp_ullong; + break; + } +#endif + + default: + { + unsigned int tmp_uint = 0; + value = &tmp_uint; break; + } } - H5Tclose(mtid); - /* remove vlen indicators */ - if ((*str)[0] == '}') - (*str)++; + + if (H5Tenum_valueof(tid, token, value) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + HDmemcpy(ucptr, value, typeSize); + + retVal = typeSize; + + break; } - break; - default: - { - /* All other types get copied raw */ - HDmemcpy(ucptr, this_str, size); - } - break; - } /* end switch */ + case H5T_ARRAY: + { + hsize_t i, dims[H5S_MAX_RANK], total_elmts; + size_t baseTypeSize; + int rank = 0; - return this_strlen; -} /* end h5str_convert */ + /* Skip whitespace and array indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == '[') this_str++; + while (*this_str == ' ') this_str++; -/** print value of a vlen data point into string. - Return Value: - On success, the total number of characters printed is returned. - On error, a negative number is returned. - */ -size_t -h5str_vlsprintf - (h5str_t *str, hid_t container, hid_t tid, hvl_t *ptr, int expand_data) -{ - unsigned char tmp_uchar = 0; - char tmp_char = 0; - unsigned short tmp_ushort = 0; - short tmp_short = 0; - unsigned int tmp_uint = 0; - int tmp_int = 0; - unsigned long tmp_ulong = 0; - long tmp_long = 0; - unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; - float tmp_float = 0.0; - double tmp_double = 0.0; - long double tmp_ldouble = 0.0; - static char fmt_llong[8], fmt_ullong[8]; - - hid_t mtid = -1; - size_t offset; - size_t nll; - char *this_str; - size_t this_strlen; - int n; - H5T_class_t tclass = H5Tget_class(tid); - size_t size = H5Tget_size(tid); - H5T_sign_t nsign = H5Tget_sign(tid); - int bdata_print = 0; - - if (!str || !ptr) - return 0; + if ((mtid = H5Tget_super(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - /* Build default formats for long long types */ - if (!fmt_llong[0]) { - sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); - } /* end if */ + if (!(baseTypeSize = H5Tget_size(mtid))) + H5_LIBRARY_ERROR(ENVONLY); - this_str = NULL; - this_strlen = 0; + if ((rank = H5Tget_array_ndims(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - switch (tclass) { - case H5T_COMPOUND: - { - unsigned i; - n = H5Tget_nmembers(tid); - h5str_append(str, " {"); + if (H5Tget_array_dims2(tid, dims) < 0) + H5_LIBRARY_ERROR(ENVONLY); - for (i = 0; i < n; i++) { - offset = H5Tget_member_offset(tid, i); - mtid = H5Tget_member_type(tid, i); - h5str_sprintf(str, container, mtid, ((char *) (ptr->p)) + offset, ptr->len, expand_data); - if ((i + 1) < n) - h5str_append(str, ", "); - H5Tclose(mtid); + for (i = 0, total_elmts = 1; i < (hsize_t) rank; i++) + total_elmts *= dims[i]; + + if (NULL == (cptr = (char *) HDcalloc((size_t)total_elmts, baseTypeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate array buffer"); + + for (i = 0; i < total_elmts; i++) { + if (!(h5str_convert(ENVONLY, &this_str, container, mtid, out_buf, i * baseTypeSize))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + goto done; + } + + /* Skip whitespace and commas */ + while (*this_str == ' ') this_str++; + if (*this_str == ',') this_str++; + while (*this_str == ' ') this_str++; } - h5str_append(str, "} "); + + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; + + /* Skip whitespace and array indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == ']') this_str++; + while (*this_str == ' ') this_str++; + + retVal = typeSize * total_elmts; + + break; } - break; - case H5T_ARRAY: + + case H5T_VLEN: { - int rank = 0; - hsize_t i, dims[H5S_MAX_RANK], total_elmts; - h5str_append(str, "[ "); + size_t i, baseTypeSize; + hvl_t *vl_buf = (hvl_t *) out_buf; + char cur_char; + + if ((mtid = H5Tget_super(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(baseTypeSize = H5Tget_size(mtid))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (vl_buf->p = HDmalloc(baseTypeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to allocate vlen buffer"); + vl_buf->len = 1; + + /* Skip whitespace and vlen indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == '(') this_str++; + while (*this_str == ' ') this_str++; + + cur_char = *this_str; + for (i = 0; cur_char != ')' && cur_char != '\0'; i++) { + if (i >= vl_buf->len) { + char *tmp_realloc; + + if (NULL == (tmp_realloc = (char *) HDrealloc(vl_buf->p, vl_buf->len * 2 * baseTypeSize))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_convert: failed to reallocate vlen buffer"); + vl_buf->len *= 2; + vl_buf->p = tmp_realloc; + } - mtid = H5Tget_super(tid); - size = H5Tget_size(mtid); - rank = H5Tget_array_ndims(tid); + if (!(h5str_convert(ENVONLY, &this_str, container, mtid, vl_buf->p, i * baseTypeSize))) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + vl_buf->len = i; + goto done; + } - H5Tget_array_dims2(tid, dims); + /* Skip whitespace and commas */ + while (*this_str == ' ') this_str++; + if (*this_str == ',') this_str++; + while (*this_str == ' ') this_str++; + } - total_elmts = 1; - for (i = 0; i < rank; i++) - total_elmts *= dims[i]; + vl_buf->len = i; - h5str_sprintf(str, container, mtid, ((char *) (ptr->p)), ptr->len, expand_data); - H5Tclose(mtid); - h5str_append(str, " ] "); + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; + + /* Skip whitespace and vlen indicators */ + while (*this_str == ' ') this_str++; + if (*this_str == ')') this_str++; + while (*this_str == ' ') this_str++; + + retVal = typeSize; + + break; + } + + case H5T_NCLASSES: + case H5T_NO_CLASS: + { + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_convert: invalid datatype class"); + break; + } + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + default: + { + /* All other types get copied raw */ + HDmemcpy(ucptr, this_str, typeSize); + + retVal = typeSize; + + break; } - break; - default: - this_strlen = h5str_sprintf(str, container, tid, ((char *) (ptr->p)), ptr->len, expand_data); - break; } /* end switch */ - return this_strlen; -} /* end h5str_vlsprintf */ +done: + if (mtid >= 0) + H5Tclose(mtid); + + return retVal; +} /* end h5str_convert */ -/** print value of a data point into string. - Return Value: - On success, the total number of characters printed is returned. - On error, a negative number is returned. +/* + * Prints the value of a data point into a string. + * + * Returns: + * SUCCESS: Total number of characters printed + * FAILURE: 0 */ size_t h5str_sprintf - (h5str_t *str, hid_t container, hid_t tid, void *ptr, int ptr_len, int expand_data) + (JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, int expand_data) { - unsigned char tmp_uchar = 0; - char tmp_char = 0; - unsigned short tmp_ushort = 0; - short tmp_short = 0; - unsigned int tmp_uint = 0; - int tmp_int = 0; - unsigned long tmp_ulong = 0; - long tmp_long = 0; - unsigned long long tmp_ullong = 0; - long long tmp_llong = 0; - float tmp_float = 0.0; - double tmp_double = 0.0; - long double tmp_ldouble = 0.0; - static char fmt_llong[8], fmt_ullong[8]; - - hid_t mtid = -1; - size_t offset; - size_t nll; - char *this_str; - size_t this_strlen; - int n; - char *cptr = (char*) (ptr); - unsigned char *ucptr = (unsigned char*) (ptr); - H5T_class_t tclass = H5Tget_class(tid); - size_t size = H5Tget_size(tid); - H5T_sign_t nsign = H5Tget_sign(tid); - int bdata_print = 0; - - if (!str || !ptr) - return 0; + unsigned char *ucptr = (unsigned char *) in_buf; + static char fmt_llong[8], fmt_ullong[8]; + H5T_class_t tclass = H5T_NO_CLASS; + size_t typeSize = 0; + hid_t mtid = H5I_INVALID_HID; + char *cptr = (char *) in_buf; + char *this_str = NULL; + int n; + size_t retVal = 0; + + if (!out_str) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: out_str is NULL"); + if (!in_buf) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: in_buf is NULL"); + + if (H5T_NO_CLASS == (tclass = H5Tget_class(tid))) + H5_LIBRARY_ERROR(ENVONLY); + if (!(typeSize = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); /* Build default formats for long long types */ if (!fmt_llong[0]) { - sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); - sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); + if (HDsprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); + if (HDsprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: sprintf failure"); } /* end if */ - this_str = NULL; - this_strlen = 0; - switch (tclass) { - case H5T_FLOAT: - if (sizeof(float) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */ - HDmemcpy(&tmp_float, cptr, sizeof(float)); - this_str = (char*)HDmalloc(25); - sprintf(this_str, "%g", tmp_float); - } - else if (sizeof(double) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_DOUBLE)) */ - HDmemcpy(&tmp_double, cptr, sizeof(double)); - this_str = (char*)HDmalloc(25); - sprintf(this_str, "%g", tmp_double); - } -#if H5_SIZEOF_LONG_DOUBLE !=0 - else if (sizeof(long double) == size) { - /* if (H5Tequal(tid, H5T_NATIVE_LDOUBLE)) */ - HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); - this_str = (char*)HDmalloc(27); - sprintf(this_str, "%Lf", tmp_ldouble); - } -#endif - break; - case H5T_STRING: - { - char *tmp_str; - size = 0; + case H5T_FLOAT: + { + switch (typeSize) { + case sizeof(float): + { + float tmp_float = 0.0; - if (H5Tis_variable_str(tid)) { - tmp_str = *(char**) ptr; - if (tmp_str != NULL) - size = HDstrlen(tmp_str); - } - else { - tmp_str = cptr; - } + HDmemcpy(&tmp_float, cptr, sizeof(float)); - /* Check for NULL pointer for string */ - if (tmp_str == NULL) { - this_str = (char *)HDmalloc(5); - HDstrncpy(this_str, "NULL", 4); - } - else { - if (size > 0) { - this_str = (char *)HDmalloc(size+1); - HDstrncpy(this_str, tmp_str, size); - } - } - } - break; - case H5T_INTEGER: - if (sizeof(char) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */ - HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); - this_str = (char*)HDmalloc(7); - sprintf(this_str, "%u", tmp_uchar); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_SCHAR)) */ - HDmemcpy(&tmp_char, cptr, sizeof(char)); - this_str = (char*)HDmalloc(7); - sprintf(this_str, "%hhd", tmp_char); - } - } - else if (sizeof(int) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */ - HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); - this_str = (char*)HDmalloc(14); - sprintf(this_str, "%u", tmp_uint); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_INT)) */ - HDmemcpy(&tmp_int, cptr, sizeof(int)); - this_str = (char*)HDmalloc(14); - sprintf(this_str, "%d", tmp_int); + if (NULL == (this_str = (char *) HDmalloc(25))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%g", tmp_float) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + + break; + } + + case sizeof(double): + { + double tmp_double = 0.0; + + HDmemcpy(&tmp_double, cptr, sizeof(double)); + + if (NULL == (this_str = (char *) HDmalloc(25))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%g", tmp_double) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + + break; + } +#if H5_SIZEOF_LONG_DOUBLE != 0 + case sizeof(long double): + { + long double tmp_ldouble = 0.0; + + HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); + + if (NULL == (this_str = (char *) HDmalloc(27))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%Lf", tmp_ldouble) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + + break; + } +#endif + + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: floating-point datatype size didn't match any of expected sizes"); + break; } + + break; } - else if (sizeof(short) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */ - HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); - this_str = (char*)HDmalloc(9); - sprintf(this_str, "%u", tmp_ushort); + + case H5T_STRING: + { + htri_t is_variable; + char *tmp_str; + + typeSize = 0; + + if ((is_variable = H5Tis_variable_str(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (is_variable) { + if (NULL != (tmp_str = *(char **) in_buf)) + typeSize = HDstrlen(tmp_str); } else { - /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */ - HDmemcpy(&tmp_short, cptr, sizeof(short)); - this_str = (char*)HDmalloc(9); - sprintf(this_str, "%d", tmp_short); + tmp_str = cptr; } - } - else if (sizeof(long) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */ - HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); - this_str = (char*)HDmalloc(23); - sprintf(this_str, "%lu", tmp_ulong); + + /* Check for NULL pointer for string */ + if (!tmp_str) { + if (NULL == (this_str = (char *) HDmalloc(5))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + HDstrncpy(this_str, "NULL", 5); } else { - /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */ - HDmemcpy(&tmp_long, cptr, sizeof(long)); - this_str = (char*)HDmalloc(23); - sprintf(this_str, "%ld", tmp_long); + if (typeSize > 0) { + if (NULL == (this_str = (char *) HDmalloc(typeSize + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + HDstrncpy(this_str, tmp_str, typeSize); + } } + + break; } - else if (sizeof(long long) == size) { - if(H5T_SGN_NONE == nsign) { - /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */ - HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); - this_str = (char*)HDmalloc(25); - sprintf(this_str, fmt_ullong, tmp_ullong); - } - else { - /* if (H5Tequal(tid, H5T_NATIVE_LLONG)) */ - HDmemcpy(&tmp_llong, cptr, sizeof(long long)); - this_str = (char*)HDmalloc(25); - sprintf(this_str, fmt_llong, tmp_llong); + + case H5T_INTEGER: + { + H5T_sign_t nsign = H5T_SGN_ERROR; + + if (H5T_SGN_ERROR == (nsign = H5Tget_sign(tid))) + H5_LIBRARY_ERROR(ENVONLY); + + switch (typeSize) { + case sizeof(char): + { + unsigned char tmp_uchar = 0; + char tmp_char = 0; + + if (H5T_SGN_NONE == nsign) { + HDmemcpy(&tmp_uchar, cptr, sizeof(unsigned char)); + + if (NULL == (this_str = (char *) HDmalloc(7))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%u", tmp_uchar) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + HDmemcpy(&tmp_char, cptr, sizeof(char)); + + if (NULL == (this_str = (char *) HDmalloc(7))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%hhd", tmp_char) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; + } + + case sizeof(short): + { + unsigned short tmp_ushort = 0; + short tmp_short = 0; + + if (H5T_SGN_NONE == nsign) { + HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); + + if (NULL == (this_str = (char *) HDmalloc(9))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%u", tmp_ushort) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + HDmemcpy(&tmp_short, cptr, sizeof(short)); + + if (NULL == (this_str = (char *) HDmalloc(9))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%d", tmp_short) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; + } + + case sizeof(int): + { + unsigned int tmp_uint = 0; + int tmp_int = 0; + + if (H5T_SGN_NONE == nsign) { + HDmemcpy(&tmp_uint, cptr, sizeof(unsigned int)); + + if (NULL == (this_str = (char *) HDmalloc(14))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%u", tmp_uint) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + HDmemcpy(&tmp_int, cptr, sizeof(int)); + + if (NULL == (this_str = (char *) HDmalloc(14))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%d", tmp_int) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; + } + + case sizeof(long): + { + unsigned long tmp_ulong = 0; + long tmp_long = 0; + + if (H5T_SGN_NONE == nsign) { + HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); + + if (NULL == (this_str = (char *) HDmalloc(23))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%lu", tmp_ulong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + HDmemcpy(&tmp_long, cptr, sizeof(long)); + + if (NULL == (this_str = (char *) HDmalloc(23))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, "%ld", tmp_long) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; + } + +#if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG + case sizeof(long long): + { + unsigned long long tmp_ullong = 0; + long long tmp_llong = 0; + + if (H5T_SGN_NONE == nsign) { + HDmemcpy(&tmp_ullong, cptr, sizeof(unsigned long long)); + + if (NULL == (this_str = (char *) HDmalloc(25))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, fmt_ullong, tmp_ullong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + HDmemcpy(&tmp_llong, cptr, sizeof(long long)); + + if (NULL == (this_str = (char *) HDmalloc(25))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (HDsprintf(this_str, fmt_llong, tmp_llong) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; + } +#endif + + default: + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: integer datatype size didn't match any of expected sizes"); + break; } + + break; } - break; - case H5T_COMPOUND: - { - unsigned i; - n = H5Tget_nmembers(tid); - h5str_append(str, " {"); - - for (i = 0; i < n; i++) { - offset = H5Tget_member_offset(tid, i); - mtid = H5Tget_member_type(tid, i); - h5str_sprintf(str, container, mtid, cptr + offset, ptr_len, expand_data); - if ((i + 1) < n) - h5str_append(str, ", "); - H5Tclose(mtid); - } - h5str_append(str, "} "); - } - break; - case H5T_ENUM: - { - char enum_name[1024]; - if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) { - h5str_append(str, enum_name); + + case H5T_COMPOUND: + { + unsigned i; + size_t offset; + + if ((n = H5Tget_nmembers(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_append(out_str, H5_COMPOUND_BEGIN_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + for (i = 0; i < (unsigned) n; i++) { + offset = H5Tget_member_offset(tid, i); + + if ((mtid = H5Tget_member_type(tid, i)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &cptr[offset], in_buf_len, expand_data)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if ((i + 1) < (unsigned) n) + if (!h5str_append(out_str, ", ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; + } + + if (!h5str_append(out_str, H5_COMPOUND_END_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; } - else { - size_t i; - nll = H5Tget_size(tid); - this_str = (char*)HDmalloc(4 * (nll + 1)); - if (1 == nll) { - sprintf(this_str, "%#02x", ucptr[0]); + case H5T_ENUM: + { + char enum_name[1024]; + + if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) { + if (!h5str_append(out_str, enum_name)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } else { - for (i = 0; i < (int)nll; i++) - sprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]); + size_t i; + + if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (1 == typeSize) { + if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + for (i = 0; i < typeSize; i++) + if (HDsprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } } + + break; } - } - break; - case H5T_REFERENCE: - if (h5str_is_zero(cptr, size)) { - h5str_append(str, "NULL"); - } - else { - if (H5R_DSET_REG_REF_BUF_SIZE == size) { - /* if (H5Tequal(tid, H5T_STD_REF_DSETREG)) */ + + case H5T_REFERENCE: + { + if (h5str_is_zero(cptr, 99)) { + if (!h5str_append(out_str, "NULL")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + break; + } + + if (H5R_DSET_REG_REF_BUF_SIZE == typeSize) { + H5S_sel_type region_type = H5S_SEL_ERROR; + hid_t region_obj = H5I_INVALID_HID; + hid_t region = H5I_INVALID_HID; + char ref_name[1024]; + /* * Dataset region reference -- * show the type and the referenced object */ - char ref_name[1024]; - hid_t region_obj; - hid_t region; - H5S_sel_type region_type; - /* get name of the dataset the region reference points to using H5Rget_name */ - region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr); - if (region_obj >= 0) { - region = H5Rget_region(container, H5R_DATASET_REGION, cptr); - if (region >= 0) { - if(expand_data) { - region_type = H5Sget_select_type(region); - if(region_type==H5S_SEL_POINTS) { - h5str_dump_region_points_data(str, region, region_obj); - } - else { - h5str_dump_region_blocks_data(str, region, region_obj); - } - } - else { - if(H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char*)ref_name, 1024) >= 0) { - h5str_append(str, ref_name); - } - - region_type = H5Sget_select_type(region); - - if(region_type==H5S_SEL_POINTS) { - h5str_append(str, " REGION_TYPE POINT"); - h5str_dump_region_points(str, region, region_obj); - } - else { - h5str_append(str, " REGION_TYPE BLOCK"); - h5str_dump_region_blocks(str, region, region_obj); - } - } + /* Get name of the dataset the region reference points to using H5Rget_name */ + if ((region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((region = H5Rget_region(container, H5R_DATASET_REGION, cptr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (expand_data) { + if (H5S_SEL_ERROR == (region_type = H5Sget_select_type(region))) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5S_SEL_POINTS == region_type) { + if (h5str_dump_region_points_data(ENVONLY, out_str, region, region_obj) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else { + if (h5str_dump_region_blocks_data(ENVONLY, out_str, region, region_obj) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + } + else { + if (H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char *)ref_name, 1024) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_append(out_str, ref_name)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (H5S_SEL_ERROR == (region_type = H5Sget_select_type(region))) + H5_LIBRARY_ERROR(ENVONLY); - H5Sclose(region); + if (H5S_SEL_POINTS == region_type) { + if (!h5str_append(out_str, " REGION_TYPE POINT")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (h5str_dump_region_points(ENVONLY, out_str, region, region_obj) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else { + if (!h5str_append(out_str, " REGION_TYPE BLOCK")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (h5str_dump_region_blocks(ENVONLY, out_str, region, region_obj) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } - H5Dclose(region_obj); } + + if (H5Sclose(region) < 0) + H5_LIBRARY_ERROR(ENVONLY); + region = H5I_INVALID_HID; + + if (H5Dclose(region_obj) < 0) + H5_LIBRARY_ERROR(ENVONLY); + region_obj = H5I_INVALID_HID; } - else if (H5R_OBJ_REF_BUF_SIZE == size) { - /* if (H5Tequal(tid, H5T_STD_REF_OBJ)) */ + else if (H5R_OBJ_REF_BUF_SIZE == typeSize) { + H5O_info_t oi; + hid_t obj = H5I_INVALID_HID; + /* * Object references -- show the type and OID of the referenced * object. */ - H5O_info_t oi; - hid_t obj; - this_str = (char*)HDmalloc(64); - obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr); - H5Oget_info2(obj, &oi, H5O_INFO_ALL); + if (NULL == (this_str = (char *) HDmalloc(64))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if ((obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Oget_info2(obj, &oi, H5O_INFO_ALL) < 0) + H5_LIBRARY_ERROR(ENVONLY); /* Print object data and close object */ - sprintf(this_str, "%u-%lu", (unsigned) oi.type, oi.addr); - H5Oclose(obj); + if (HDsprintf(this_str, "%u-%lu", (unsigned) oi.type, oi.addr) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + + if (H5Oclose(obj) < 0) + H5_LIBRARY_ERROR(ENVONLY); + obj = H5I_INVALID_HID; } + + break; } - break; - case H5T_ARRAY: - { - int rank = 0; - hsize_t i, dims[H5S_MAX_RANK], total_elmts; - h5str_append(str, "[ "); - mtid = H5Tget_super(tid); - size = H5Tget_size(mtid); - rank = H5Tget_array_ndims(tid); + case H5T_ARRAY: + { + hsize_t dims[H5S_MAX_RANK], i, total_elmts; + size_t baseSize; + int rank = 0; + + if (!h5str_append(out_str, H5_ARRAY_BEGIN_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if ((mtid = H5Tget_super(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(baseSize = H5Tget_size(mtid))) + H5_LIBRARY_ERROR(ENVONLY); + + if ((rank = H5Tget_array_ndims(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Tget_array_dims2(tid, dims) < 0) + H5_LIBRARY_ERROR(ENVONLY); - H5Tget_array_dims2(tid, dims); + for (i = 0, total_elmts = 1; i < (hsize_t) rank; i++) + total_elmts *= dims[i]; + + for (i = 0; i < total_elmts; i++) { + if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(cptr[i * baseSize]), in_buf_len, expand_data)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if ((i + 1) < total_elmts) + if (!h5str_append(out_str, ", ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + + if (!h5str_append(out_str, H5_ARRAY_END_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - total_elmts = 1; - for (i = 0; i < rank; i++) - total_elmts *= dims[i]; + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; - for (i = 0; i < total_elmts; i++) { - h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data); - if ((i + 1) < total_elmts) - h5str_append(str, ", "); + break; } - H5Tclose(mtid); - h5str_append(str, " ] "); - } - break; - case H5T_VLEN: + + case H5T_VLEN: { - unsigned int i; - mtid = H5Tget_super(tid); - size = H5Tget_size(mtid); - - h5str_append(str, "{"); - for (i = 0; i < (int)ptr_len; i++) { - h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data); - if ((i + 1) < (int)ptr_len) - h5str_append(str, ", "); + unsigned int i; + size_t baseSize; + hvl_t *vl_buf = (hvl_t *) in_buf; + + if ((mtid = H5Tget_super(tid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(baseSize = H5Tget_size(mtid))) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_append(out_str, H5_VLEN_BEGIN_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + for (i = 0; i < (unsigned) vl_buf->len; i++) { + if (!h5str_sprintf(ENVONLY, out_str, container, mtid, &(((char *) vl_buf->p)[i * baseSize]), vl_buf->len, expand_data)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if ((i + 1) < (unsigned) vl_buf->len) + if (!h5str_append(out_str, ", ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } - H5Tclose(mtid); - h5str_append(str, "}"); - } - break; - default: - { - /* All other types get printed as hexadecimal */ - size_t i; - nll = H5Tget_size(tid); - this_str = (char*)HDmalloc(4 * (nll + 1)); + if (!h5str_append(out_str, H5_VLEN_END_INDICATOR)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (1 == nll) { - sprintf(this_str, "%#02x", ucptr[0]); + if (H5Tclose(mtid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + mtid = H5I_INVALID_HID; + + break; } - else { - for (i = 0; i < (int)nll; i++) - sprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]); + + case H5T_NO_CLASS: + case H5T_NCLASSES: + { + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_sprintf: invalid datatype class"); + break; + } + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + default: + { + size_t i; + + /* All other types get printed as hexadecimal */ + + if (NULL == (this_str = (char *) HDmalloc(4 * (typeSize + 1)))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); + + if (1 == typeSize) { + if (HDsprintf(this_str, "%#02x", ucptr[0]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + else { + for (i = 0; i < typeSize; i++) + if (HDsprintf(this_str, "%s%02x", i ? ":" : "", ucptr[i]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: HDsprintf failure"); + } + + break; } } - break; - } /* end switch */ if (this_str) { - h5str_append(str, this_str); - this_strlen = HDstrlen(str->s); + if (!h5str_append(out_str, this_str)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + HDfree(this_str); + this_str = NULL; } /* end if */ - return this_strlen; + retVal = HDstrlen(out_str->s); + +done: + if (mtid >= 0) + H5Tclose(mtid); + + return retVal; } /* end h5str_sprintf */ /*------------------------------------------------------------------------- @@ -1020,113 +1214,115 @@ h5str_sprintf */ static int h5str_print_region_data_blocks - (hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) + (JNIEnv *env, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) { - hsize_t *dims1 = NULL; - hsize_t *start = NULL; - hsize_t *count = NULL; - hsize_t blkndx; - hsize_t total_size[H5S_MAX_RANK]; - hsize_t numelem; - hsize_t numindex; - size_t jndx; - unsigned indx; - size_t type_size; - int ret_value = SUCCEED; - hid_t mem_space = -1; - hid_t sid1 = -1; - void *region_buf = NULL; + unsigned indx; + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t blkndx; + hsize_t total_size[H5S_MAX_RANK]; + hsize_t numelem; + hsize_t numindex; + size_t jndx; + size_t type_size; + hid_t mem_space = H5I_INVALID_HID; + hid_t sid1 = H5I_INVALID_HID; + void *region_buf = NULL; + int ret_value = FAIL; + + if (ndims < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_print_region_data_blocks: ndims < 0"); + if (nblocks < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_print_region_data_blocks: nblocks < 0"); /* Get the dataspace of the dataset */ - if((sid1 = H5Dget_space(region_id)) >= 0) { + if ((sid1 = H5Dget_space(region_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - - /* find the dimensions of each data space from the block coordinates */ - numelem = 1; - for (jndx = 0; jndx < ndims; jndx++) { - dims1[jndx] = ptdata[jndx + (size_t)ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; - } /* end for */ - - /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) { - if((type_size = H5Tget_size(type_id)) > 0) { - if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) { - /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ - /* 1 2 n 1 2 n */ - if((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - if((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - for (blkndx = 0; blkndx < nblocks; blkndx++) { - for (indx = 0; indx < ndims; indx++) { - start[indx] = ptdata[indx + blkndx * (hsize_t)ndims * 2]; - count[indx] = dims1[indx]; - } /* end for */ - - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { - if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { - for (numindex = 0; numindex < numelem; numindex++) { - h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 0, 1); - - if (numindex + 1 < numelem) - h5str_append(str, ", "); - } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ - } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ - } /* end if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) */ - } /* end if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) */ - } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ - - HDfree(count); - } /* end if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - - HDfree(start); - } /* end if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; + /* Allocate space for the dimension array */ + if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate dimension array buffer"); - HDfree(region_buf); - } /* end if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) */ - else - ret_value = -1; - } /* end if((type_size = H5Tget_size(type_id)) > 0) */ - else - ret_value = -1; - - if(H5Sclose(mem_space) < 0) - ret_value = -1; - } /* end if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) */ - else - ret_value = -1; - - HDfree(dims1); - } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - - if(H5Sclose(sid1) < 0) - ret_value = -1; - } /* end if((sid1 = H5Dget_space(region_id)) >= 0) */ - else - ret_value = -1; + /* Find the dimensions of each data space from the block coordinates */ + for (jndx = 0, numelem = 1; jndx < (size_t) ndims; jndx++) { + dims1[jndx] = ptdata[jndx + (size_t)ndims] - ptdata[jndx] + 1; + numelem = dims1[jndx] * numelem; + } /* end for */ + + /* Create dataspace for reading buffer */ + if ((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!(type_size = H5Tget_size(type_id))) + H5_LIBRARY_ERROR(ENVONLY); + + if (NULL == (region_buf = HDmalloc(type_size * (size_t)numelem))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate region buffer"); + + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab start buffer"); + + if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_blocks: failed to allocate hyperslab count buffer"); + + for (blkndx = 0; blkndx < (hsize_t) nblocks; blkndx++) { + for (indx = 0; indx < (unsigned) ndims; indx++) { + start[indx] = ptdata[indx + blkndx * (hsize_t)ndims * 2]; + count[indx] = dims1[indx]; + } /* end for */ + + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + for (numindex = 0; numindex < numelem; numindex++) { + if (!h5str_sprintf(ENVONLY, str, region_id, type_id, ((char *)region_buf + numindex * type_size), 0, 1)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (numindex + 1 < numelem) + if (!h5str_append(str, ", ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } /* end for (jndx = 0; jndx < numelem; jndx++, region_elmtno++, ctx.cur_elmt++) */ + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + + ret_value = SUCCEED; + +done: + if (count) + HDfree(count); + if (start) + HDfree(start); + if (region_buf) + HDfree(region_buf); + if (mem_space >= 0) + H5Sclose(mem_space); + if (dims1) + HDfree(dims1); + if (sid1 >= 0) + H5Sclose(sid1); return ret_value; } /* end h5str_print_region_data_blocks */ int h5str_dump_region_blocks_data - (h5str_t *str, hid_t region, hid_t region_id) + (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - int ret_value = 0; - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata; - hid_t dtype = -1; - hid_t type_id = -1; - int ndims = H5Sget_simple_extent_ndims(region); + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims = -1; + int ret_value = FAIL; /* * This function fails if the region does not have blocks. @@ -1135,50 +1331,56 @@ h5str_dump_region_blocks_data nblocks = H5Sget_select_hyper_nblocks(region); } H5E_END_TRY; + if (nblocks < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((ndims = H5Sget_simple_extent_ndims(region)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + /* Print block information */ - if (nblocks > 0) { - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); - H5Sget_select_hyper_blocklist(region, (hsize_t) 0, - (hsize_t) nblocks, ptdata); + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks_data: failed to allocate region block buffer"); + if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if((dtype = H5Dget_type(region_id)) >= 0) { - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + if ((dtype = H5Dget_type(region_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - h5str_print_region_data_blocks(region_id, str, ndims, type_id, nblocks, ptdata); + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if(H5Tclose(type_id) < 0) - ret_value = -1; - } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ - else - ret_value = -1; + if (h5str_print_region_data_blocks(ENVONLY, region_id, str, ndims, type_id, nblocks, ptdata) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ - if(H5Tclose(dtype) < 0) - ret_value = -1; - } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ - else - ret_value = -1; - HDfree(ptdata); - } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ - } /* if (nblocks > 0) */ + ret_value = SUCCEED; + +done: + if (type_id >= 0) + H5Tclose(type_id); + if (dtype >= 0) + H5Tclose(dtype); + if (ptdata) + HDfree(ptdata); return ret_value; } /* end h5str_dump_region_blocks_data */ static int h5str_dump_region_blocks - (h5str_t *str, hid_t region, hid_t region_id) + (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - int ret_value = 0; - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata; - hid_t dtype = -1; - hid_t type_id = -1; - char tmp_str[256]; - int ndims = H5Sget_simple_extent_ndims(region); + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + char tmp_str[256]; + int ndims = -1; + int ret_value = FAIL; + + UNUSED(region_id); /* * This function fails if the region does not have blocks. @@ -1187,44 +1389,70 @@ h5str_dump_region_blocks nblocks = H5Sget_select_hyper_nblocks(region); } H5E_END_TRY; + if (nblocks < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((ndims = H5Sget_simple_extent_ndims(region)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + /* Print block information */ - if (nblocks > 0) { + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + if (alloc_size == (hsize_t)((size_t) alloc_size)) { int i; - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if (alloc_size == (hsize_t)((size_t) alloc_size)) { - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); - H5Sget_select_hyper_blocklist(region, (hsize_t) 0, - (hsize_t) nblocks, ptdata); + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: failed to allocate region block buffer"); - h5str_append(str, " {"); - for (i = 0; i < nblocks; i++) { - int j; + if (H5Sget_select_hyper_blocklist(region, (hsize_t) 0, (hsize_t) nblocks, ptdata) < 0) + H5_LIBRARY_ERROR(ENVONLY); - h5str_append(str, " "); + if (!h5str_append(str, " {")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - /* Start coordinates and opposite corner */ - for (j = 0; j < ndims; j++) { - tmp_str[0] = '\0'; - sprintf(tmp_str, "%s%lu", j ? "," : "(", - (unsigned long) ptdata[i * 2 * ndims + j]); - h5str_append(str, tmp_str); - } + for (i = 0; i < nblocks; i++) { + int j; - for (j = 0; j < ndims; j++) { - tmp_str[0] = '\0'; - sprintf(tmp_str, "%s%lu", j ? "," : ")-(", - (unsigned long) ptdata[i * 2 * ndims + j + ndims]); - h5str_append(str, tmp_str); - } - h5str_append(str, ") "); + if (!h5str_append(str, " ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + /* Start coordinates and opposite corner */ + for (j = 0; j < ndims; j++) { + tmp_str[0] = '\0'; + + if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", + (unsigned long) ptdata[i * 2 * ndims + j]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); + + if (!h5str_append(str, tmp_str)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + + for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; + + if (HDsprintf(tmp_str, "%s%lu", j ? "," : ")-(", + (unsigned long) ptdata[i * 2 * ndims + j + ndims]) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_blocks: HDsprintf failure"); + + if (!h5str_append(str, tmp_str)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } - h5str_append(str, " }"); - HDfree(ptdata); - } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ - } /* if (nblocks > 0) */ + if (!h5str_append(str, ") ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + tmp_str[0] = '\0'; + } + + if (!h5str_append(str, " }")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } /* if (alloc_size == (hsize_t)((size_t)alloc_size)) */ + + ret_value = SUCCEED; + +done: + if (ptdata) + HDfree(ptdata); return ret_value; } /* end h5str_dump_region_blocks */ @@ -1241,76 +1469,76 @@ h5str_dump_region_blocks */ static int h5str_print_region_data_points - (hid_t region_space, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) + (JNIEnv *env, hid_t region_space, hid_t region_id, h5str_t *str, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { - hsize_t *dims1 = NULL; - hsize_t total_size[H5S_MAX_RANK]; - size_t jndx; - size_t type_size; - int ret_value = SUCCEED; - hid_t mem_space = -1; - void *region_buf = NULL; + hsize_t *dims1 = NULL; + hsize_t total_size[H5S_MAX_RANK]; + size_t jndx; + size_t type_size; + hid_t mem_space = H5I_INVALID_HID; + void *region_buf = NULL; + int ret_value = FAIL; + + UNUSED(ptdata); + + if (npoints < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_print_region_data_points: npoints < 0"); /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { + if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate dimension array buffer"); - dims1[0] = (hsize_t)npoints; + dims1[0] = (hsize_t)npoints; - /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) { + /* Create dataspace for reading buffer */ + if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if((type_size = H5Tget_size(type_id)) > 0) { + if (!(type_size = H5Tget_size(type_id))) + H5_LIBRARY_ERROR(ENVONLY); - if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) { + if (NULL == (region_buf = HDmalloc(type_size * (size_t)npoints))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_print_region_data_points: failed to allocate region buffer"); - if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) { + if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) + H5_LIBRARY_ERROR(ENVONLY); - for (jndx = 0; jndx < npoints; jndx++) { - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { + for (jndx = 0; jndx < (size_t) npoints; jndx++) { + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); - h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 0, 1); + if (!h5str_sprintf(ENVONLY, str, region_id, type_id, ((char *)region_buf + jndx * type_size), 0, 1)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (jndx + 1 < npoints) - h5str_append(str, ", "); + if (jndx + 1 < (size_t) npoints) + if (!h5str_append(str, ", ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ - } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ - } /* end for (jndx = 0; jndx < npoints; jndx++, elmtno++) */ - } /* end if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) */ - else - ret_value = -1; + ret_value = SUCCEED; - HDfree(region_buf); - } /* end if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) */ - else - ret_value = -1; - } /* end if((type_size = H5Tget_size(type_id)) > 0) */ - else - ret_value = -1; - - if(H5Sclose(mem_space) < 0) - ret_value = -1; - } /* end if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) */ - else - ret_value = -1; +done: + if (region_buf) + HDfree(region_buf); + if (mem_space >= 0) + H5Sclose(mem_space); + if (dims1) HDfree(dims1); - } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; return ret_value; } /* end h5str_print_region_data_points */ int h5str_dump_region_points_data - (h5str_t *str, hid_t region, hid_t region_id) + (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - int ret_value = 0; - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata; - hid_t dtype = -1; - hid_t type_id = -1; - int ndims = H5Sget_simple_extent_ndims(region); + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims = -1; + int ret_value = FAIL; /* * This function fails if the region does not have points. @@ -1319,50 +1547,59 @@ h5str_dump_region_points_data npoints = H5Sget_select_elem_npoints(region); } H5E_END_TRY; + if (npoints < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((ndims = H5Sget_simple_extent_ndims(region)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + /* Print point information */ if (npoints > 0) { alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); - H5Sget_select_elem_pointlist(region, (hsize_t) 0, - (hsize_t) npoints, ptdata); + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points_data: failed to allocate region point data buffer"); - if((dtype = H5Dget_type(region_id)) >= 0) { - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { + if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) + H5_LIBRARY_ERROR(ENVONLY); - h5str_print_region_data_points(region, region_id, - str, ndims, type_id, npoints, ptdata); + if ((dtype = H5Dget_type(region_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if(H5Tclose(type_id) < 0) - ret_value = -1; - } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ - else - ret_value = -1; - - if(H5Tclose(dtype) < 0) - ret_value = -1; - } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ - else - ret_value = -1; - HDfree(ptdata); + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (h5str_print_region_data_points(ENVONLY, region, region_id, + str, ndims, type_id, npoints, ptdata) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } } + ret_value = SUCCEED; + +done: + if (type_id >= 0) + H5Tclose(type_id); + if (dtype >= 0) + H5Tclose(dtype); + if (ptdata) + HDfree(ptdata); + return ret_value; } /* end h5str_dump_region_points_data */ static int h5str_dump_region_points - (h5str_t *str, hid_t region, hid_t region_id) + (JNIEnv *env, h5str_t *str, hid_t region, hid_t region_id) { - int ret_value = 0; - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata; - char tmp_str[256]; - hid_t dtype = -1; - hid_t type_id = -1; - int ndims = H5Sget_simple_extent_ndims(region); + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + char tmp_str[256]; + int ndims = -1; + int ret_value = FAIL; + + UNUSED(region_id); /* * This function fails if the region does not have points. @@ -1371,37 +1608,59 @@ h5str_dump_region_points npoints = H5Sget_select_elem_npoints(region); } H5E_END_TRY; + if (npoints < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((ndims = H5Sget_simple_extent_ndims(region)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + /* Print point information */ if (npoints > 0) { int i; alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { - ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); - H5Sget_select_elem_pointlist(region, (hsize_t) 0, - (hsize_t) npoints, ptdata); + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t) alloc_size))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: failed to allocate region point buffer"); + + if (H5Sget_select_elem_pointlist(region, (hsize_t) 0, (hsize_t) npoints, ptdata) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (!h5str_append(str, " {")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - h5str_append(str, " {"); for (i = 0; i < npoints; i++) { int j; - h5str_append(str, " "); + if (!h5str_append(str, " ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); for (j = 0; j < ndims; j++) { tmp_str[0] = '\0'; - sprintf(tmp_str, "%s%lu", j ? "," : "(", - (unsigned long) (ptdata[i * ndims + j])); - h5str_append(str, tmp_str); + + if (HDsprintf(tmp_str, "%s%lu", j ? "," : "(", + (unsigned long) (ptdata[i * ndims + j])) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_region_points: HDsprintf failure"); + + if (!h5str_append(str, tmp_str)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end for (j = 0; j < ndims; j++) */ - h5str_append(str, ") "); + if (!h5str_append(str, ") ")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end for (i = 0; i < npoints; i++) */ - h5str_append(str, " }"); - HDfree(ptdata); + if (!h5str_append(str, " }")) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); } /* end if (alloc_size == (hsize_t)((size_t) alloc_size)) */ } /* end if (npoints > 0) */ + ret_value = SUCCEED; + +done: + if (ptdata) + HDfree(ptdata); + return ret_value; } /* end h5str_dump_region_points */ @@ -1419,6 +1678,37 @@ h5str_is_zero } /* end h5str_is_zero */ /*------------------------------------------------------------------------- + * Function: h5str_detect_vlen + * + * Purpose: Recursive check for any variable length data in given type. + * + * Return: + * 1 : type contains any variable length data + * 0 : type doesn't contain any variable length data + * Negative value: error occurred + *------------------------------------------------------------------------- + */ +static htri_t +h5str_detect_vlen + (hid_t tid) +{ + htri_t ret = FAIL; + + /* Recursively detect any vlen data values in type (compound, array ...) */ + ret = H5Tdetect_class(tid, H5T_VLEN); + if ((ret == 1) || (ret < 0)) + goto done; + + /* Recursively detect any vlen string in type (compound, array ...) */ + ret = h5str_detect_vlen_str(tid); + if ((ret == 1) || (ret < 0)) + goto done; + +done: + return ret; +} /* end h5str_detect_vlen */ + +/*------------------------------------------------------------------------- * Function: h5str_detect_vlen_str * * Purpose: Recursive check for variable length string of a datatype. @@ -1459,12 +1749,10 @@ h5str_detect_vlen_str unsigned i = 0; int n = H5Tget_nmembers(tid); - if(n < 0) { - n = ret; + if (n < 0) goto done; - } /* end if */ - for(i = 0; i < n; i++) { + for(i = 0; i < (unsigned) n; i++) { hid_t mtid = H5Tget_member_type(tid, i); ret = h5str_detect_vlen_str(mtid); @@ -1494,15 +1782,18 @@ static hid_t h5str_get_native_type (hid_t type) { - hid_t p_type; H5T_class_t type_class; + hid_t p_type = H5I_INVALID_HID; + + if ((type_class = H5Tget_class(type)) < 0) + goto done; - type_class = H5Tget_class(type); - if(type_class==H5T_BITFIELD) - p_type=H5Tcopy(type); + if (type_class == H5T_BITFIELD) + p_type = H5Tcopy(type); else - p_type = H5Tget_native_type(type,H5T_DIR_DEFAULT); + p_type = H5Tget_native_type(type, H5T_DIR_DEFAULT); +done: return(p_type); } /* end h5str_get_native_type */ @@ -1520,73 +1811,89 @@ static hid_t h5str_get_little_endian_type (hid_t tid) { - hid_t p_type=-1; H5T_class_t type_class; - size_t size; H5T_sign_t sign; + size_t size; + hid_t p_type = H5I_INVALID_HID; - type_class = H5Tget_class(tid); - size = H5Tget_size(tid); - sign = H5Tget_sign(tid); + if ((type_class = H5Tget_class(tid)) < 0) + goto done; - switch( type_class ) - { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8LE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16LE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32LE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64LE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8LE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16LE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32LE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64LE); - } - break; + if (!(size = H5Tget_size(tid))) + goto done; - case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32LE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64LE); - break; + if ((sign = H5Tget_sign(tid)) < 0) + goto done; - case H5T_BITFIELD: - { - if ( size == 1) - p_type=H5Tcopy(H5T_STD_B8LE); - else if ( size == 2) - p_type=H5Tcopy(H5T_STD_B16LE); - else if ( size == 4) - p_type=H5Tcopy(H5T_STD_B32LE); - else if ( size == 8) - p_type=H5Tcopy(H5T_STD_B64LE); - } - break; + switch ( type_class ) { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I8LE); + else if ( size == 2 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I16LE); + else if ( size == 4 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I32LE); + else if ( size == 8 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I64LE); + else if ( size == 1 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U8LE); + else if ( size == 2 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U16LE); + else if ( size == 4 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U32LE); + else if ( size == 8 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U64LE); + + break; + } + + case H5T_FLOAT: + { + if ( size == 4 ) + p_type = H5Tcopy(H5T_IEEE_F32LE); + else if ( size == 8 ) + p_type = H5Tcopy(H5T_IEEE_F64LE); - case H5T_TIME: - case H5T_OPAQUE: - case H5T_STRING: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - break; + break; + } + + case H5T_BITFIELD: + { + if ( size == 1 ) + p_type = H5Tcopy(H5T_STD_B8LE); + else if ( size == 2 ) + p_type = H5Tcopy(H5T_STD_B16LE); + else if ( size == 4 ) + p_type = H5Tcopy(H5T_STD_B32LE); + else if ( size == 8 ) + p_type = H5Tcopy(H5T_STD_B64LE); + + break; + } - default: - break; + case H5T_NO_CLASS: + case H5T_NCLASSES: + { + goto done; + break; + } + case H5T_TIME: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; } +done: return(p_type); } /* end h5str_get_little_endian_type */ @@ -1594,115 +1901,100 @@ h5str_get_little_endian_type * Function: h5str_get_big_endian_type * * Purpose: Get a big endian type from a file type - * - * Return: Success: datatype ID - * Failure: FAIL - *------------------------------------------------------------------------- - */ -static hid_t -h5str_get_big_endian_type - (hid_t tid) -{ - hid_t p_type=-1; - H5T_class_t type_class; - size_t size; - H5T_sign_t sign; - - type_class = H5Tget_class(tid); - size = H5Tget_size(tid); - sign = H5Tget_sign(tid); - - switch( type_class ) - { - case H5T_INTEGER: - { - if ( size == 1 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I8BE); - else if ( size == 2 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I16BE); - else if ( size == 4 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I32BE); - else if ( size == 8 && sign == H5T_SGN_2) - p_type=H5Tcopy(H5T_STD_I64BE); - else if ( size == 1 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U8BE); - else if ( size == 2 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U16BE); - else if ( size == 4 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U32BE); - else if ( size == 8 && sign == H5T_SGN_NONE) - p_type=H5Tcopy(H5T_STD_U64BE); - } - break; - - case H5T_FLOAT: - if ( size == 4) - p_type=H5Tcopy(H5T_IEEE_F32BE); - else if ( size == 8) - p_type=H5Tcopy(H5T_IEEE_F64BE); - break; - - case H5T_BITFIELD: - { - if ( size == 1) - p_type=H5Tcopy(H5T_STD_B8BE); - else if ( size == 2) - p_type=H5Tcopy(H5T_STD_B16BE); - else if ( size == 4) - p_type=H5Tcopy(H5T_STD_B32BE); - else if ( size == 8) - p_type=H5Tcopy(H5T_STD_B64BE); - } - break; - - case H5T_TIME: - case H5T_OPAQUE: - case H5T_STRING: - case H5T_COMPOUND: - case H5T_REFERENCE: - case H5T_ENUM: - case H5T_VLEN: - case H5T_ARRAY: - break; - - default: - break; - - } - - return(p_type); -} /* end h5str_get_big_endian_type */ - -/*------------------------------------------------------------------------- - * Function: h5str_detect_vlen - * - * Purpose: Recursive check for any variable length data in given type. - * - * Return: - * 1 : type conatains any variable length data - * 0 : type doesn't contain any variable length data - * Negative value: error occur + * + * Return: Success: datatype ID + * Failure: FAIL *------------------------------------------------------------------------- */ -static htri_t -h5str_detect_vlen +static hid_t +h5str_get_big_endian_type (hid_t tid) { - htri_t ret; + H5T_class_t type_class; + H5T_sign_t sign; + size_t size; + hid_t p_type = H5I_INVALID_HID; - /* recursive detect any vlen data values in type (compound, array ...) */ - ret = H5Tdetect_class(tid, H5T_VLEN); - if((ret == 1) || (ret < 0)) + if ((type_class = H5Tget_class(tid)) < 0) goto done; - /* recursive detect any vlen string in type (compound, array ...) */ - ret = h5str_detect_vlen_str(tid); - if((ret == 1) || (ret < 0)) + if (!(size = H5Tget_size(tid))) + goto done; + + if ((sign = H5Tget_sign(tid)) < 0) goto done; + switch ( type_class ) { + case H5T_INTEGER: + { + if ( size == 1 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I8BE); + else if ( size == 2 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I16BE); + else if ( size == 4 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I32BE); + else if ( size == 8 && sign == H5T_SGN_2 ) + p_type = H5Tcopy(H5T_STD_I64BE); + else if ( size == 1 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U8BE); + else if ( size == 2 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U16BE); + else if ( size == 4 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U32BE); + else if ( size == 8 && sign == H5T_SGN_NONE ) + p_type = H5Tcopy(H5T_STD_U64BE); + + break; + } + + case H5T_FLOAT: + { + if ( size == 4 ) + p_type = H5Tcopy(H5T_IEEE_F32BE); + else if ( size == 8 ) + p_type = H5Tcopy(H5T_IEEE_F64BE); + + break; + } + + case H5T_BITFIELD: + { + if ( size == 1 ) + p_type = H5Tcopy(H5T_STD_B8BE); + else if ( size == 2 ) + p_type = H5Tcopy(H5T_STD_B16BE); + else if ( size == 4 ) + p_type = H5Tcopy(H5T_STD_B32BE); + else if ( size == 8 ) + p_type = H5Tcopy(H5T_STD_B64BE); + + break; + } + + case H5T_NO_CLASS: + case H5T_NCLASSES: + { + goto done; + break; + } + + case H5T_TIME: + case H5T_OPAQUE: + case H5T_STRING: + case H5T_COMPOUND: + case H5T_REFERENCE: + case H5T_ENUM: + case H5T_VLEN: + case H5T_ARRAY: + break; + + default: + break; + } + done: - return ret; -} /* end h5str_detect_vlen */ + return(p_type); +} /* end h5str_get_big_endian_type */ /*------------------------------------------------------------------------- * Function: render_bin_output @@ -1717,201 +2009,261 @@ static int h5str_render_bin_output (FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t block_nelmts) { - int ret_value = 0; - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t block_index; - H5T_class_t type_class; - - if((size = H5Tget_size(tid)) > 0) { - - if((type_class = H5Tget_class(tid)) >= 0) { - - switch (type_class) { - case H5T_INTEGER: - case H5T_FLOAT: - case H5T_ENUM: - block_index = block_nelmts * size; - while(block_index > 0) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ - size_t item_size = size; /* size of items in bytes */ - - if(block_index > sizeof(size_t)) - bytes_in = sizeof(size_t); - else - bytes_in = (size_t)block_index; + unsigned char *mem = (unsigned char*)_mem; + H5T_class_t type_class; + hsize_t block_index; + size_t size; /* datum size */ + int ret_value = 0; + + if (!(size = H5Tget_size(tid))) { + ret_value = FAIL; + goto done; + } + + if ((type_class = H5Tget_class(tid)) < 0) { + ret_value = FAIL; + goto done; + } - bytes_wrote = fwrite(mem, 1, bytes_in, stream); + switch (type_class) { + case H5T_INTEGER: + case H5T_FLOAT: + case H5T_ENUM: + { + block_index = block_nelmts * size; + while (block_index > 0) { + size_t bytes_in = 0; /* # of bytes to write */ + size_t bytes_wrote = 0; /* # of bytes written */ - if(bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(stream))) { - ret_value = -1; - break; - } + if (block_index > sizeof(size_t)) + bytes_in = sizeof(size_t); + else + bytes_in = (size_t)block_index; - block_index -= (hsize_t)bytes_wrote; - mem = mem + bytes_wrote; - } + bytes_wrote = fwrite(mem, 1, bytes_in, stream); + + if (bytes_wrote != bytes_in || (0 == bytes_wrote && ferror(stream))) { + ret_value = FAIL; break; - case H5T_STRING: - { - unsigned int i; - H5T_str_t pad; - char *s; - unsigned char tempuchar; + } - pad = H5Tget_strpad(tid); + block_index -= (hsize_t)bytes_wrote; + mem = mem + bytes_wrote; + } - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; + break; + } - if (H5Tis_variable_str(tid)) { - s = *(char**) mem; - if (s != NULL) - size = HDstrlen(s); - } - else { - s = (char *) mem; - } - for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { - HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); - if (1 != fwrite(&tempuchar, sizeof(unsigned char), 1, stream)) { - ret_value = -1; - break; - } - } /* i */ - if(ret_value < 0) - break; - } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ + case H5T_STRING: + { + unsigned char tempuchar; + unsigned int i; + H5T_str_t pad; + char *s; + + if ((pad = H5Tget_strpad(tid)) < 0) { + ret_value = FAIL; + goto done; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char *)_mem) + block_index * size; + + if (H5Tis_variable_str(tid)) { + s = *(char**) mem; + if (s != NULL) + size = HDstrlen(s); } - break; - case H5T_COMPOUND: - { - unsigned j; - hid_t memb; - unsigned nmembs; - size_t offset; - - nmembs = (unsigned)H5Tget_nmembers(tid); - - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - for (j = 0; j < nmembs; j++) { - offset = H5Tget_member_offset(tid, j); - memb = H5Tget_member_type(tid, j); - - if (h5str_render_bin_output(stream, container, memb, mem + offset, 1) < 0) { - H5Tclose(memb); - ret_value = -1; - break; - } - - H5Tclose(memb); - } - if(ret_value < 0) - break; - } + else { + s = (char *) mem; } - break; - case H5T_ARRAY: - { - int k, ndims; - hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; - hid_t memb; - - /* get the array's base datatype for each element */ - memb = H5Tget_super(tid); - ndims = H5Tget_array_ndims(tid); - H5Tget_array_dims2(tid, dims); - - /* calculate the number of array elements */ - for (k = 0, nelmts = 1; k < ndims; k++) { - temp_nelmts = nelmts; - temp_nelmts *= dims[k]; - nelmts = (size_t) temp_nelmts; + for (i = 0; i < size && (s[i] || pad != H5T_STR_NULLTERM); i++) { + HDmemcpy(&tempuchar, &s[i], sizeof(unsigned char)); + if (1 != fwrite(&tempuchar, sizeof(unsigned char), 1, stream)) { + ret_value = FAIL; + break; } + } /* i */ + if (ret_value < 0) + break; + } /* for (block_index = 0; block_index < block_nelmts; block_index++) */ - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - /* dump the array element */ - if (h5str_render_bin_output(stream, container, memb, mem, nelmts) < 0) { - ret_value = -1; - break; - } + break; + } + + case H5T_COMPOUND: + { + unsigned j; + size_t offset; + hid_t memb = H5I_INVALID_HID; + int nmembs; + + if ((nmembs = H5Tget_nmembers(tid)) < 0) { + ret_value = FAIL; + goto done; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + for (j = 0; j < (unsigned) nmembs; j++) { + offset = H5Tget_member_offset(tid, j); + memb = H5Tget_member_type(tid, j); + + if (h5str_render_bin_output(stream, container, memb, mem + offset, 1) < 0) { + H5Tclose(memb); + ret_value = FAIL; + break; } + H5Tclose(memb); } - break; - case H5T_VLEN: - { - hsize_t nelmts; - hid_t memb; - /* get the VL sequences's base datatype for each element */ - memb = H5Tget_super(tid); + if (ret_value < 0) + break; + } + + break; + } - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - /* Get the number of sequence elements */ - nelmts = ((hvl_t *) mem)->len; + case H5T_ARRAY: + { + hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hid_t memb; + int k, ndims; - /* dump the array element */ - if (h5str_render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) { - ret_value = -1; - break; - } - } - H5Tclose(memb); + /* Get the array's base datatype for each element */ + if ((memb = H5Tget_super(tid)) < 0) { + ret_value = FAIL; + goto done; + } + + if ((ndims = H5Tget_array_ndims(tid)) < 0) { + ret_value = FAIL; + goto done; + } + + if (H5Tget_array_dims2(tid, dims) < 0) { + ret_value = FAIL; + goto done; + } + + /* Calculate the number of array elements */ + for (k = 0, nelmts = 1; k < ndims; k++) { + temp_nelmts = nelmts; + temp_nelmts *= dims[k]; + nelmts = (size_t) temp_nelmts; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + + /* dump the array element */ + if (h5str_render_bin_output(stream, container, memb, mem, nelmts) < 0) { + ret_value = FAIL; + break; } - break; - case H5T_REFERENCE: - { - if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { - /* region data */ - hid_t region_id, region_space; - H5S_sel_type region_type; - - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem); - if (region_id >= 0) { - region_space = H5Rget_region(container, H5R_DATASET_REGION, mem); - if (region_space >= 0) { - region_type = H5Sget_select_type(region_space); - if(region_type == H5S_SEL_POINTS) - ret_value = render_bin_output_region_points(stream, region_space, region_id, container); - else - ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container); - H5Sclose(region_space); - } /* end if (region_space >= 0) */ - H5Dclose(region_id); - } /* end if (region_id >= 0) */ - if(ret_value < 0) - break; - } + } + + H5Tclose(memb); + + break; + } + + case H5T_VLEN: + { + hsize_t nelmts; + hid_t memb; + + /* Get the VL sequences's base datatype for each element */ + if ((memb = H5Tget_super(tid)) < 0) { + ret_value = FAIL; + goto done; + } + + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + + /* Get the number of sequence elements */ + nelmts = ((hvl_t *) mem)->len; + + /* dump the array element */ + if (h5str_render_bin_output(stream, container, memb, ((char *) (((hvl_t *) mem)->p)), nelmts) < 0) { + ret_value = FAIL; + break; + } + } + + H5Tclose(memb); + + break; + } + + case H5T_REFERENCE: + { + if (H5Tequal(tid, H5T_STD_REF_DSETREG)) { + H5S_sel_type region_type; + hid_t region_id, region_space; + + /* Region data */ + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + + if ((region_id = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, mem)) < 0) + continue; + + if ((region_space = H5Rget_region(container, H5R_DATASET_REGION, mem)) < 0) { + H5Dclose(region_id); + continue; } - else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { - ; + + if ((region_type = H5Sget_select_type(region_space)) < 0) { + H5Sclose(region_space); + H5Dclose(region_id); + continue; } + + if (region_type == H5S_SEL_POINTS) + ret_value = render_bin_output_region_points(stream, region_space, region_id, container); + else + ret_value = render_bin_output_region_blocks(stream, region_space, region_id, container); + + H5Sclose(region_space); + H5Dclose(region_id); + + if (ret_value < 0) + break; } - break; - default: - for (block_index = 0; block_index < block_nelmts; block_index++) { - mem = ((unsigned char*)_mem) + block_index * size; - if (size != fwrite(mem, sizeof(char), size, stream)) { - ret_value = -1; - break; - } - } + } + else if (H5Tequal(tid, H5T_STD_REF_OBJ)) { + ; + } + + break; + } + + case H5T_NO_CLASS: + case H5T_NCLASSES: + { + ret_value = FAIL; + goto done; + break; + } + + case H5T_TIME: + case H5T_BITFIELD: + case H5T_OPAQUE: + default: + for (block_index = 0; block_index < block_nelmts; block_index++) { + mem = ((unsigned char*)_mem) + block_index * size; + if (size != fwrite(mem, sizeof(char), size, stream)) { + ret_value = FAIL; break; + } } - } /* end if((type_class = H5Tget_class(tid)) >= 0) */ - else - ret_value = -1; - } /* end if((size = H5Tget_size(tid)) > 0) */ - else - ret_value = -1; + break; + } +done: return ret_value; } /* end h5str_render_bin_output */ @@ -1930,96 +2282,107 @@ static int render_bin_output_region_data_blocks (FILE *stream, hid_t region_id, hid_t container, int ndims, hid_t type_id, hssize_t nblocks, hsize_t *ptdata) { - hsize_t *dims1 = NULL; - hsize_t *start = NULL; - hsize_t *count = NULL; - hsize_t numelem; - hsize_t total_size[H5S_MAX_RANK]; - int jndx; - size_t type_size; - hid_t mem_space = -1; - void *region_buf = NULL; - int blkndx; - hid_t sid1 = -1; - int ret_value = SUCCEED; + hsize_t *dims1 = NULL; + hsize_t *start = NULL; + hsize_t *count = NULL; + hsize_t numelem; + hsize_t total_size[H5S_MAX_RANK]; + size_t type_size; + hid_t sid1 = H5I_INVALID_HID; + hid_t mem_space = H5I_INVALID_HID; + void *region_buf = NULL; + int blkndx; + int jndx; + int ret_value = SUCCEED; /* Get the dataspace of the dataset */ - if((sid1 = H5Dget_space(region_id)) >= 0) { - /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - /* find the dimensions of each data space from the block coordinates */ - numelem = 1; - for (jndx = 0; jndx < ndims; jndx++) { - dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; - numelem = dims1[jndx] * numelem; - } + if ((sid1 = H5Dget_space(region_id)) < 0) { + ret_value = FAIL; + goto done; + } - /* Create dataspace for reading buffer */ - if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) { - if((type_size = H5Tget_size(type_id)) > 0) { - if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) { - /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ - /* 1 2 n 1 2 n */ - if((start = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - if((count = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - for (blkndx = 0; blkndx < nblocks; blkndx++) { - for (jndx = 0; jndx < ndims; jndx++) { - start[jndx] = ptdata[jndx + blkndx * ndims * 2]; - count[jndx] = dims1[jndx]; - } - - if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) { - if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) { - if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { - ret_value = h5str_render_bin_output(stream, container, type_id, (char*)region_buf, numelem); - } /* end if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) */ - else { - ret_value = -1; - break; - } - } /* end if(H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) >= 0) */ - else { - ret_value = -1; - break; - } - } /* end if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) >= 0) */ - else { - ret_value = -1; - break; - } - /* Render the region data element end */ - } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ - - HDfree(count); - } /* end if((count = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - HDfree(start); - } /* end if((start = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - HDfree(region_buf); - } /* end if((region_buf = HDmalloc(type_size * (size_t)numelem)) != NULL) */ - else - ret_value = -1; - } /* end if((type_size = H5Tget_size(type_id)) > 0) */ - else - ret_value = -1; - - if(H5Sclose(mem_space) < 0) - ret_value = -1; - } /* end if((mem_space = H5Screate_simple(ndims, dims1, NULL)) >= 0) */ - else - ret_value = -1; - HDfree(dims1); - } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - if(H5Sclose(sid1) < 0) - ret_value = -1; - } /* end if((sid1 = H5Dget_space(region_id)) >= 0) */ - else - ret_value = -1; + /* Allocate space for the dimension array */ + if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + ret_value = FAIL; + goto done; + } + + /* Find the dimensions of each data space from the block coordinates */ + for (jndx = 0, numelem = 1; jndx < ndims; jndx++) { + dims1[jndx] = ptdata[jndx + ndims] - ptdata[jndx] + 1; + numelem = dims1[jndx] * numelem; + } + + /* Create dataspace for reading buffer */ + if ((mem_space = H5Screate_simple(ndims, dims1, NULL)) < 0) { + ret_value = FAIL; + goto done; + } + + if (!(type_size = H5Tget_size(type_id))) { + ret_value = FAIL; + goto done; + } + + if (NULL == (region_buf = HDmalloc(type_size * (size_t)numelem))) { + ret_value = FAIL; + goto done; + } + + /* Select (x , x , ..., x ) x (y , y , ..., y ) hyperslab for reading memory dataset */ + /* 1 2 n 1 2 n */ + if (NULL == (start = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + ret_value = FAIL; + goto done; + } + + if (NULL == (count = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + ret_value = FAIL; + goto done; + } + + for (blkndx = 0; blkndx < nblocks; blkndx++) { + for (jndx = 0; jndx < ndims; jndx++) { + start[jndx] = ptdata[jndx + blkndx * ndims * 2]; + count[jndx] = dims1[jndx]; + } + + if (H5Sselect_hyperslab(sid1, H5S_SELECT_SET, start, NULL, count, NULL) < 0) { + ret_value = FAIL; + goto done; + } + + if (H5Dread(region_id, type_id, mem_space, sid1, H5P_DEFAULT, region_buf) < 0) { + ret_value = FAIL; + goto done; + } + + if (H5Sget_simple_extent_dims(mem_space, total_size, NULL) < 0) { + ret_value = FAIL; + goto done; + } + + if (h5str_render_bin_output(stream, container, type_id, (char *)region_buf, numelem) < 0) { + ret_value = FAIL; + goto done; + } + + /* Render the region data element end */ + } /* end for (blkndx = 0; blkndx < nblocks; blkndx++) */ + +done: + if (count) + HDfree(count); + if (start) + HDfree(start); + if (region_buf) + HDfree(region_buf); + if (mem_space >= 0) + H5Sclose(mem_space); + if (dims1) + HDfree(dims1); + if (sid1 >= 0) + H5Sclose(sid1); return ret_value; } /* end render_bin_output_region_data_blocks */ @@ -2039,50 +2402,62 @@ static int render_bin_output_region_blocks (FILE *stream, hid_t region_space, hid_t region_id, hid_t container) { - int ret_value = SUCCEED; - hssize_t nblocks; - hsize_t alloc_size; - hsize_t *ptdata = NULL; - int ndims; - hid_t dtype; - hid_t type_id; - - if((nblocks = H5Sget_select_hyper_nblocks(region_space)) > 0) { + hssize_t nblocks; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims; + int ret_value = SUCCEED; + + if ((nblocks = H5Sget_select_hyper_nblocks(region_space)) < 0) { + ret_value = FAIL; + goto done; + } + + if (nblocks > 0) { /* Print block information */ - if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) { - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); - if((ptdata = (hsize_t*)HDmalloc((size_t)alloc_size)) != NULL) { - if(H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, (hsize_t)nblocks, ptdata) >= 0) { - if((dtype = H5Dget_type(region_id)) >= 0) { - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { - ret_value = render_bin_output_region_data_blocks(stream, region_id, container, ndims, - type_id, nblocks, ptdata); - - if(H5Tclose(type_id) < 0) - ret_value = -1; - } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ - else - ret_value = -1; + if ((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) { + ret_value = FAIL; + goto done; + } - if(H5Tclose(dtype) < 0) - ret_value = -1; - } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ - else - ret_value = -1; - } /* end if(H5Sget_select_hyper_blocklist(region_space, (hsize_t) 0, (hsize_t) nblocks, ptdata) >= 0) */ - else - ret_value = -1; - - HDfree(ptdata); - } /* end if((ptdata = (hsize_t*) HDmalloc((size_t) alloc_size)) != NULL) */ - else - ret_value = -1; - } /* end if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) */ - else - ret_value = -1; - } /* end if((nblocks = H5Sget_select_hyper_nblocks(region_space)) > 0) */ - else - ret_value = -1; + alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); + + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t)alloc_size))) { + ret_value = FAIL; + goto done; + } + + if (H5Sget_select_hyper_blocklist(region_space, (hsize_t)0, (hsize_t)nblocks, ptdata) < 0) { + ret_value = FAIL; + goto done; + } + + if ((dtype = H5Dget_type(region_id)) < 0) { + ret_value = FAIL; + goto done; + } + + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if (render_bin_output_region_data_blocks(stream, region_id, container, + ndims, type_id, nblocks, ptdata) < 0) { + ret_value = FAIL; + goto done; + } + } + +done: + if (type_id >= 0) + H5Tclose(type_id); + if (dtype >= 0) + H5Tclose(dtype); + if (ptdata) + HDfree(ptdata); return ret_value; } /* end render_bin_output_region_blocks */ @@ -2105,43 +2480,57 @@ render_bin_output_region_data_points { hsize_t *dims1 = NULL; size_t type_size; - hid_t mem_space = -1; + hid_t mem_space = H5I_INVALID_HID; void *region_buf = NULL; int ret_value = SUCCEED; - if((type_size = H5Tget_size(type_id)) > 0) { - if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) { - /* Allocate space for the dimension array */ - if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { - dims1[0] = (hsize_t)npoints; - if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) { - if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) { - if(H5Sget_simple_extent_dims(region_space, dims1, NULL) >= 0) { - ret_value = h5str_render_bin_output(stream, container, type_id, (char*)region_buf, (hsize_t)npoints); - } /* end if(H5Sget_simple_extent_dims(region_space, dims1, NULL) >= 0) */ - else - ret_value = -1; - } /* end if(H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) >= 0) */ - else - ret_value = -1; - } /* end if((mem_space = H5Screate_simple(1, dims1, NULL)) >= 0) */ - else - ret_value = -1; - - HDfree(dims1); - } /* end if((dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * ndims)) != NULL) */ - else - ret_value = -1; - HDfree(region_buf); - } /* end if((region_buf = HDmalloc(type_size * (size_t)npoints)) != NULL) */ - else - ret_value = -1; - - if(H5Sclose(mem_space) < 0) - ret_value = -1; - } /* end if((type_size = H5Tget_size(type_id)) > 0) */ - else - ret_value = -1; + UNUSED(ptdata); + + if (!(type_size = H5Tget_size(type_id))) { + ret_value = FAIL; + goto done; + } + + if (NULL == (region_buf = HDmalloc(type_size * (size_t)npoints))) { + ret_value = FAIL; + goto done; + } + + /* Allocate space for the dimension array */ + if (NULL == (dims1 = (hsize_t *) HDmalloc(sizeof(hsize_t) * (size_t)ndims))) { + ret_value = FAIL; + goto done; + } + + dims1[0] = (hsize_t)npoints; + + if ((mem_space = H5Screate_simple(1, dims1, NULL)) < 0) { + ret_value = FAIL; + goto done; + } + + if (H5Dread(region_id, type_id, mem_space, region_space, H5P_DEFAULT, region_buf) < 0) { + ret_value = FAIL; + goto done; + } + + if (H5Sget_simple_extent_dims(region_space, dims1, NULL) < 0) { + ret_value = FAIL; + goto done; + } + + if (h5str_render_bin_output(stream, container, type_id, (char *)region_buf, (hsize_t)npoints) < 0) { + ret_value = FAIL; + goto done; + } + +done: + if (dims1) + HDfree(dims1); + if (mem_space >= 0) + H5Sclose(mem_space); + if (region_buf) + HDfree(region_buf); return ret_value; } /* end render_bin_output_region_data_points */ @@ -2161,248 +2550,343 @@ static int render_bin_output_region_points (FILE *stream, hid_t region_space, hid_t region_id, hid_t container) { - int ret_value = SUCCEED; - hssize_t npoints; - hsize_t alloc_size; - hsize_t *ptdata; - int ndims; - hid_t dtype; - hid_t type_id; - - if((npoints = H5Sget_select_elem_npoints(region_space)) > 0) { + hssize_t npoints; + hsize_t alloc_size; + hsize_t *ptdata = NULL; + hid_t dtype = H5I_INVALID_HID; + hid_t type_id = H5I_INVALID_HID; + int ndims; + int ret_value = SUCCEED; + + if ((npoints = H5Sget_select_elem_npoints(region_space)) < 0) { + ret_value = FAIL; + goto done; + } + + if (npoints > 0) { /* Allocate space for the dimension array */ - if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) { - alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); - if(NULL != (ptdata = (hsize_t *)HDmalloc((size_t)alloc_size))) { - if(H5Sget_select_elem_pointlist(region_space, (hsize_t)0, (hsize_t)npoints, ptdata) >= 0) { - if((dtype = H5Dget_type(region_id)) >= 0) { - if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) { - ret_value = render_bin_output_region_data_points(stream, region_space, region_id, - container, ndims, type_id, npoints, ptdata); - - if(H5Tclose(type_id) < 0) - ret_value = -1; - } /* end if((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) >= 0) */ - else - ret_value = -1; + if ((ndims = H5Sget_simple_extent_ndims(region_space)) < 0) { + ret_value = FAIL; + goto done; + } - if(H5Tclose(dtype) < 0) - ret_value = -1; - } /* end if((dtype = H5Dget_type(region_id)) >= 0) */ - else - ret_value = -1; - } /* end if(H5Sget_select_elem_pointlist(region_space, (hsize_t) 0, (hsize_t) npoints, ptdata) >= 0) */ - else - ret_value = -1; + alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); - HDfree(ptdata); - } /* end if(NULL != (ptdata = (hsize_t *)HDmalloc((size_t) alloc_size))) */ - else - ret_value = -1; - } /* end if((ndims = H5Sget_simple_extent_ndims(region_space)) >= 0) */ - else - ret_value = -1; + if (NULL == (ptdata = (hsize_t *) HDmalloc((size_t)alloc_size))) { + ret_value = FAIL; + goto done; + } - } /* end if((npoints = H5Sget_select_elem_npoints(region_space)) > 0) */ - else - ret_value = -1; + if (H5Sget_select_elem_pointlist(region_space, (hsize_t)0, (hsize_t)npoints, ptdata) < 0) { + ret_value = FAIL; + goto done; + } + + if ((dtype = H5Dget_type(region_id)) < 0) { + ret_value = FAIL; + goto done; + } + + if ((type_id = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) { + ret_value = FAIL; + goto done; + } + + if (render_bin_output_region_data_points(stream, region_space, region_id, + container, ndims, type_id, npoints, ptdata) < 0) { + ret_value = FAIL; + goto done; + } + } + +done: + if (type_id >= 0) + H5Tclose(type_id); + if (dtype >= 0) + H5Tclose(dtype); + if (ptdata) + HDfree(ptdata); return ret_value; } /* end render_bin_output_region_points */ int h5str_dump_simple_dset - (FILE *stream, hid_t dset, int binary_order) + (JNIEnv *env, FILE *stream, hid_t dset, int binary_order) { - int ret_value = SUCCEED; - hid_t f_space = -1; /* file data space */ - hsize_t elmtno; /* counter */ - size_t i; /* counter */ - int ndims; - int carry; /* counter carry value */ - hsize_t zero[8]; /* vector of zeros */ - hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + hsize_t elmtno; /* counter */ + hsize_t zero[8]; /* vector of zeros */ + hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ + size_t i; /* counter */ + hid_t f_space = H5I_INVALID_HID; /* file data space */ + int ndims; + int carry; /* counter carry value */ /* Print info */ - size_t p_type_nbytes; /* size of memory type */ - hsize_t p_nelmts; /* total selected elmts */ + hsize_t p_nelmts; /* total selected elmts */ + size_t p_type_nbytes; /* size of memory type */ /* Stripmine info */ - hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ - hsize_t sm_nbytes; /* bytes per stripmine */ - hsize_t sm_nelmts; /* elements per stripmine*/ - unsigned char *sm_buf = NULL; /* buffer for raw data */ - hid_t sm_space = -1; /* stripmine data space */ + unsigned char *sm_buf = NULL; /* buffer for raw data */ + hsize_t sm_size[H5S_MAX_RANK]; /* stripmine size */ + hsize_t sm_nbytes; /* bytes per stripmine */ + hsize_t sm_nelmts; /* elements per stripmine */ + hid_t sm_space = H5I_INVALID_HID; /* stripmine data space */ /* Hyperslab info */ - hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ - hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ - hsize_t hs_nelmts; /* elements in request */ + hsize_t hs_offset[H5S_MAX_RANK]; /* starting offset */ + hsize_t hs_size[H5S_MAX_RANK]; /* size this pass */ + hsize_t hs_nelmts; /* elements in request */ /* VL data special information */ - unsigned int vl_data = 0; /* contains VL datatypes */ - hid_t p_type = -1; - hid_t f_type = -1; - - if(dset < 0) return -1; - f_type = H5Dget_type(dset); - if (binary_order == 1) - p_type = h5str_get_native_type(f_type); - else if (binary_order == 2) - p_type = h5str_get_little_endian_type(f_type); - else if (binary_order == 3) - p_type = h5str_get_big_endian_type(f_type); - else - p_type = H5Tcopy(f_type); + unsigned int vl_data = 0; /* contains VL datatypes */ + hid_t p_type = H5I_INVALID_HID; + hid_t f_type = H5I_INVALID_HID; - H5Tclose(f_type); + int ret_value = FAIL; - if (p_type >= 0) { - if((f_space = H5Dget_space(dset)) >= 0) { - ndims = H5Sget_simple_extent_ndims(f_space); + if (dset < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "h5str_dump_simple_dset: dset ID < 0"); - if ((size_t)ndims <= (sizeof(sm_size)/sizeof(sm_size[0]))) { - H5Sget_simple_extent_dims(f_space, total_size, NULL); + if ((f_type = H5Dget_type(dset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - /* calculate the number of elements we're going to print */ - p_nelmts = 1; + switch (binary_order) { + case 1: + { + if ((p_type = h5str_get_native_type(f_type)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + case 2: + { + if ((p_type = h5str_get_little_endian_type(f_type)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + case 3: + { + if ((p_type = h5str_get_big_endian_type(f_type)) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + break; + } + + default: + { + if ((p_type = H5Tcopy(f_type)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + break; + } + } - if (ndims > 0) { - for (i = 0; i < ndims; i++) - p_nelmts *= total_size[i]; - } /* end if */ + if ((f_space = H5Dget_space(dset)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (p_nelmts > 0) { - /* Check if we have VL data in the dataset's datatype */ - if (h5str_detect_vlen(p_type) != 0) - vl_data = 1; + if ((ndims = H5Sget_simple_extent_ndims(f_space)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - /* - * Determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ - sm_nbytes = p_type_nbytes = H5Tget_size(p_type); + if ((size_t)ndims <= (sizeof(sm_size) / sizeof(sm_size[0]))) { + if (H5Sget_simple_extent_dims(f_space, total_size, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); + /* Calculate the number of elements we're going to print */ + p_nelmts = 1; + + if (ndims > 0) { + for (i = 0; i < (size_t) ndims; i++) + p_nelmts *= total_size[i]; + } /* end if */ + + if (p_nelmts > 0) { + /* Check if we have VL data in the dataset's datatype */ + if (h5str_detect_vlen(p_type) != 0) + vl_data = 1; + + /* + * Determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ + if (!(sm_nbytes = p_type_nbytes = H5Tget_size(p_type))) + H5_LIBRARY_ERROR(ENVONLY); + + if (ndims > 0) { + for (i = (size_t)ndims; i > 0; --i) { + hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; + if ( size == 0 ) /* datum size > H5TOOLS_BUFSIZE */ + size = 1; + sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size)); + sm_nbytes *= sm_size[i - 1]; + } + } + + if (sm_nbytes > 0) { + if (NULL == (sm_buf = (unsigned char *) HDmalloc((size_t)sm_nbytes))) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_simple_dset: failed to allocate sm_buf"); + + sm_nelmts = sm_nbytes / p_type_nbytes; + + if ((sm_space = H5Screate_simple(1, &sm_nelmts, NULL)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + /* The stripmine loop */ + HDmemset(hs_offset, 0, sizeof hs_offset); + HDmemset(zero, 0, sizeof zero); + + for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { + /* Calculate the hyperslab size */ if (ndims > 0) { - for (i = (size_t)ndims; i > 0; --i) { - hsize_t size = H5TOOLS_BUFSIZE / sm_nbytes; - if ( size == 0) /* datum size > H5TOOLS_BUFSIZE */ - size = 1; - sm_size[i - 1] = (((total_size[i - 1]) < (size)) ? (total_size[i - 1]) : (size)); - sm_nbytes *= sm_size[i - 1]; + for (i = 0, hs_nelmts = 1; i < (size_t) ndims; i++) { + hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i])) ? (total_size[i] - hs_offset[i]) : (sm_size[i])); + hs_nelmts *= hs_size[i]; } + + if (H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0) + H5_LIBRARY_ERROR(ENVONLY); } + else { + if (H5Sselect_all(f_space) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if(sm_nbytes > 0) { - sm_buf = (unsigned char *)HDmalloc((size_t)sm_nbytes); - - sm_nelmts = sm_nbytes / p_type_nbytes; - sm_space = H5Screate_simple(1, &sm_nelmts, NULL); - - /* The stripmine loop */ - HDmemset(hs_offset, 0, sizeof hs_offset); - HDmemset(zero, 0, sizeof zero); - - for (elmtno = 0; elmtno < p_nelmts; elmtno += hs_nelmts) { - /* Calculate the hyperslab size */ - if (ndims > 0) { - for (i = 0, hs_nelmts = 1; i < ndims; i++) { - hs_size[i] = (((total_size[i] - hs_offset[i]) < (sm_size[i])) ? (total_size[i] - hs_offset[i]) : (sm_size[i])); - hs_nelmts *= hs_size[i]; - } - - H5Sselect_hyperslab(f_space, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL); - H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL); - } - else { - H5Sselect_all(f_space); - H5Sselect_all(sm_space); - hs_nelmts = 1; - } - - /* Read the data */ - if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) >= 0) { - - if (binary_order == 99) - ret_value = h5tools_dump_simple_data(stream, dset, p_type, sm_buf, hs_nelmts); - else - ret_value = h5str_render_bin_output(stream, dset, p_type, sm_buf, hs_nelmts); - - /* Reclaim any VL memory, if necessary */ - if (vl_data) - H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf); - } - else { - ret_value = -1; - break; - } - - if(ret_value < 0) break; - - /* Calculate the next hyperslab offset */ - for (i = (size_t)ndims, carry = 1; i > 0 && carry; --i) { - hs_offset[i - 1] += hs_size[i - 1]; - - if (hs_offset[i - 1] == total_size[i - 1]) - hs_offset[i - 1] = 0; - else - carry = 0; - } - } + if (H5Sselect_all(sm_space) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + hs_nelmts = 1; + } - if(sm_buf) - HDfree(sm_buf); + /* Read the data */ + if (H5Dread(dset, p_type, sm_space, f_space, H5P_DEFAULT, sm_buf) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (binary_order == 99) { + if (h5tools_dump_simple_data(ENVONLY, stream, dset, p_type, sm_buf, hs_nelmts) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + else { + if (h5str_render_bin_output(stream, dset, p_type, sm_buf, hs_nelmts) < 0) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + + /* Reclaim any VL memory, if necessary */ + if (vl_data) { + if (H5Dvlen_reclaim(p_type, sm_space, H5P_DEFAULT, sm_buf) < 0) + H5_LIBRARY_ERROR(ENVONLY); + } + + /* Calculate the next hyperslab offset */ + for (i = (size_t)ndims, carry = 1; i > 0 && carry; --i) { + hs_offset[i - 1] += hs_size[i - 1]; + + if (hs_offset[i - 1] == total_size[i - 1]) + hs_offset[i - 1] = 0; + else + carry = 0; } - if(sm_space >= 0 && H5Sclose(sm_space) < 0) - ret_value = -1; } } - if(f_space >= 0 && H5Sclose(f_space) < 0) - ret_value = -1; - } /* end if((f_space = H5Dget_space(dset)) >= 0) */ - else - ret_value = -1; - - if (p_type >= 0) - H5Tclose(p_type); + } } + + ret_value = SUCCEED; + +done: + if (sm_space >= 0) + H5Sclose(sm_space); + if (sm_buf) + HDfree(sm_buf); + if (f_space >= 0) + H5Sclose(f_space); + if (p_type >= 0) + H5Tclose(p_type); + if (f_type >= 0) + H5Tclose(f_type); + return ret_value; } /* end h5str_dump_simple_dset */ +htri_t +H5Tdetect_variable_str(hid_t tid) { + htri_t ret_val = 0; + + if (H5Tget_class(tid) == H5T_COMPOUND) { + unsigned i; + unsigned nm = (unsigned)H5Tget_nmembers(tid); + for(i = 0; i < nm; i++) { + htri_t status = 0; + hid_t mtid = 0; + if((mtid = H5Tget_member_type(tid, i)) < 0) + return FAIL; /* exit immediately on error */ + if((status = H5Tdetect_variable_str(mtid)) < 0) + return status; /* exit immediately on error */ + ret_val |= status; + H5Tclose (mtid); + } /* end for */ + } /* end if */ + else + ret_val = H5Tis_variable_str(tid); + + return ret_val; +} /* end H5Tdetect_variable_str */ + static int h5tools_dump_simple_data - (FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts) + (JNIEnv *env, FILE *stream, hid_t container, hid_t type, void *_mem, hsize_t nelmts) { - int ret_value = 0; - int line_count; - unsigned char *mem = (unsigned char*)_mem; - size_t size; /* datum size */ - hsize_t i; /*element counter */ - h5str_t buffer; /*string into which to render */ - - if((size = H5Tget_size(type)) > 0) { - for (i = 0, line_count = 0; i < nelmts; i++, line_count++) { - size_t bytes_in = 0; /* # of bytes to write */ - size_t bytes_wrote = 0; /* # of bytes written */ - void* memref = mem + i * size; - - /* Render the data element*/ - h5str_new(&buffer, 32 * size); - bytes_in = h5str_sprintf(&buffer, container, type, memref, 0, 1); - if(i > 0) { - HDfprintf(stream, ", "); - if (line_count >= H5TOOLS_TEXT_BLOCK) { - line_count = 0; - HDfprintf(stream, "\n"); - } + unsigned char *mem = (unsigned char *)_mem; + h5str_t buffer; /* string into which to render */ + hsize_t i; /* element counter */ + size_t size; /* datum size */ + int line_count; + int ret_value = 0; + + if (!(size = H5Tget_size(type))) + H5_LIBRARY_ERROR(ENVONLY); + + for (i = 0, line_count = 0; i < nelmts; i++, line_count++) { + size_t bytes_in = 0; /* # of bytes to write */ + void *memref = mem + i * size; + + /* Render the data element*/ + h5str_new(&buffer, 32 * size); + + if (!buffer.s) + H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: failed to allocate buffer"); + + if (!(bytes_in = h5str_sprintf(ENVONLY, &buffer, container, type, memref, 0, 1))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (i > 0) { + if (HDfprintf(stream, ", ") < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: HDfprintf failure"); + + if (line_count >= H5TOOLS_TEXT_BLOCK) { + line_count = 0; + + if (HDfprintf(stream, "\n") < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: HDfprintf failure"); } - HDfprintf(stream, "%s", buffer.s); - h5str_free(&buffer); - } /* end for (i = 0; i < nelmts... */ - HDfprintf(stream, "\n"); - } /* end if((size = H5Tget_size(tid)) > 0) */ - else - ret_value = -1; + } + + if (HDfprintf(stream, "%s", buffer.s) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: HDfprintf failure"); + + h5str_free(&buffer); + } /* end for (i = 0; i < nelmts... */ + + if (HDfprintf(stream, "\n") < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5tools_dump_simple_data: HDfprintf failure"); + +done: + if (buffer.s) + h5str_free(&buffer); return ret_value; } /* end h5tools_dump_simple_data */ @@ -2421,53 +2905,68 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadComplex (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) { - herr_t status = -1; - int i; - int n; - char *rdata; - size_t max_len = 0; - size_t size; - h5str_t h5str; - hid_t p_type = -1; - jstring jstr; + h5str_t h5str; + jstring jstr; + size_t size; + size_t i; + hid_t p_type = H5I_INVALID_HID; + jsize n; + char *readBuf = NULL; + herr_t status = FAIL; + + UNUSED(clss); + + HDmemset(&h5str, 0, sizeof(h5str_t)); + + if ((p_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - p_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT); size = (((H5Tget_size(mem_type_id))>(H5Tget_size(p_type))) ? (H5Tget_size(mem_type_id)) : (H5Tget_size(p_type))); - H5Tclose(p_type); - n = ENVPTR->GetArrayLength(ENVPAR buf); - rdata = (char *)HDmalloc((size_t)n * size); - if (rdata == NULL) { - h5JNIFatalError(env, "H5AreadComplex: failed to allocate buff for read"); - } /* end if */ - else { - status = H5Aread(attr_id, mem_type_id, rdata); - if (status < 0) { - h5JNIFatalError(env, "H5AreadComplex: failed to read data"); - } /* end if */ - else { - HDmemset(&h5str, 0, sizeof(h5str_t)); - h5str_new(&h5str, 4 * size); - if (h5str.s == NULL) { - h5JNIFatalError(env, "H5AreadComplex: failed to allocate string buf"); - } /* end if */ - else { - for (i = 0; i < n; i++) { - h5str.s[0] = '\0'; - h5str_sprintf(&h5str, attr_id, mem_type_id, rdata + ((size_t)i * size), 0, 0); - jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - } /* end for */ - } /* end else */ - h5str_free(&h5str); - } /* end else */ - HDfree(rdata); - } /* end else */ + if ((n = ENVPTR->GetArrayLength(ENVONLY, buf)) <= 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5AreadComplex: read buffer length <= 0"); + } + + if (NULL == (readBuf = (char *) HDmalloc((size_t)n * size))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate read buffer"); + + if ((status = H5Aread(attr_id, mem_type_id, readBuf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + h5str_new(&h5str, 4 * size); + + if (!h5str.s) + H5_JNI_FATAL_ERROR(ENVONLY, "H5AreadComplex: failed to allocate string buffer"); + + for (i = 0; i < (size_t) n; i++) { + h5str.s[0] = '\0'; + + if (!h5str_sprintf(ENVONLY, &h5str, attr_id, mem_type_id, readBuf + (i * size), 0, 0)) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + if (NULL == (jstr = ENVPTR->NewStringUTF(ENVONLY, h5str.s))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, buf, (jsize) i, jstr); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, jstr); + } /* end for */ + +done: + if (h5str.s) + h5str_free(&h5str); + if (readBuf) + HDfree(readBuf); + if (p_type >= 0) + H5Tclose(p_type); + return status; } /* - * Copies the content of one dataset to another dataset + * Copies the content of one attribute to another attribute * Class: hdf_hdf5lib_H5 * Method: H5Acopy * Signature: (JJ)I @@ -2476,62 +2975,51 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Acopy (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) { - jbyte *buf; - herr_t retVal = -1; - hid_t src_did = (hid_t)src_id; - hid_t dst_did = (hid_t)dst_id; - hid_t tid = -1; - hid_t sid = -1; - hsize_t total_size = 0; - - - sid = H5Aget_space(src_did); - if (sid < 0) { - h5libraryError(env); - } /* end if */ - else { - tid = H5Aget_type(src_did); - if (tid < 0) { - H5Sclose(sid); - h5libraryError(env); - } /* end if */ - else { - total_size = (hsize_t)H5Sget_simple_extent_npoints(sid) * (hsize_t)H5Tget_size(tid); + hssize_t npoints; + hsize_t total_size = 0; + size_t type_size; + jbyte *buf = NULL; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + herr_t retVal = FAIL; - H5Sclose(sid); + UNUSED(clss); - buf = (jbyte *)HDmalloc( (size_t)total_size * sizeof(jbyte)); - if (buf == NULL) { - H5Tclose(tid); - h5outOfMemory( env, "H5Acopy: malloc failed"); - } /* end if */ - else { - retVal = H5Aread(src_did, tid, buf); - H5Tclose(tid); + if ((sid = H5Aget_space((hid_t)src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retVal < 0) { - HDfree(buf); - h5libraryError(env); - } /* end if */ - else { - tid = H5Aget_type(dst_did); - if (tid < 0) { - HDfree(buf); - h5libraryError(env); - } /* end if */ - else { - retVal = H5Awrite(dst_did, tid, buf); + if ((tid = H5Aget_type((hid_t)src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - H5Tclose(tid); - HDfree(buf); + if ((npoints = H5Sget_simple_extent_npoints(sid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + if (!(type_size = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + total_size = (hsize_t)npoints * (hsize_t)type_size; - if (retVal < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ - } /* end else */ + if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Acopy: failed to allocate buffer"); + + if ((retVal = H5Aread((hid_t)src_id, tid, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (H5Tclose(tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + tid = H5I_INVALID_HID; + + if ((tid = H5Aget_type((hid_t)dst_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((retVal = H5Awrite((hid_t)dst_id, tid, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (buf) + HDfree(buf); + if (tid >= 0) + H5Tclose(tid); + if (sid >= 0) + H5Sclose(sid); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Acopy */ @@ -2546,64 +3034,54 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dcopy (JNIEnv *env, jclass clss, jlong src_id, jlong dst_id) { - jbyte *buf; - herr_t retVal = -1; - hid_t src_did = (hid_t)src_id; - hid_t dst_did = (hid_t)dst_id; - hid_t tid = -1; - hid_t sid = -1; - hsize_t total_size = 0, total_allocated_size; - - total_allocated_size = H5Dget_storage_size(src_did); - if (total_allocated_size <=0) - return 0; // nothing to write; - - sid = H5Dget_space(src_did); - if (sid < 0) { - h5libraryError(env); - return -1; - } /* end if */ + hssize_t npoints; + hsize_t total_size = 0, total_allocated_size; + size_t type_size; + jbyte *buf = NULL; + hid_t tid = H5I_INVALID_HID; + hid_t sid = H5I_INVALID_HID; + herr_t retVal = FAIL; - tid = H5Dget_type(src_did); - if (tid < 0) { - H5Sclose(sid); - h5libraryError(env); - return -1; - } /* end if */ + UNUSED(clss); - total_size = (hsize_t)H5Sget_simple_extent_npoints(sid) * (hsize_t)H5Tget_size(tid); + if (!(total_allocated_size = H5Dget_storage_size((hid_t)src_id))) + return 0; // nothing to write - H5Sclose(sid); + if ((sid = H5Dget_space((hid_t)src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - buf = (jbyte*)HDmalloc((size_t)total_size * sizeof(jbyte)); - if (buf == NULL) { - H5Tclose(tid); - h5outOfMemory(env, "H5Dcopy: malloc failed"); - return -1; - } /* end if */ + if ((tid = H5Dget_type((hid_t)src_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - retVal = H5Dread(src_did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Tclose(tid); + if ((npoints = H5Sget_simple_extent_npoints(sid)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + if (!(type_size = H5Tget_size(tid))) + H5_LIBRARY_ERROR(ENVONLY); + total_size = (hsize_t)npoints * (hsize_t)type_size; - if (retVal < 0) { - HDfree(buf); - h5libraryError(env); - return (jint)retVal; - } /* end if */ + if (NULL == (buf = (jbyte *) HDmalloc((size_t)total_size * sizeof(jbyte)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Dcopy: failed to allocate buffer"); - tid = H5Dget_type(dst_did); - if (tid < 0) { - HDfree(buf); - h5libraryError(env); - return -1; - } /* end if */ - retVal = H5Dwrite(dst_did, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf); - H5Tclose(tid); - HDfree(buf); + if ((retVal = H5Dread((hid_t)src_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retVal < 0) { - h5libraryError(env); - } /* end if */ + if (H5Tclose(tid) < 0) + H5_LIBRARY_ERROR(ENVONLY); + tid = H5I_INVALID_HID; + + if ((tid = H5Dget_type((hid_t)dst_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if ((retVal = H5Dwrite((hid_t)dst_id, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (buf) + HDfree(buf); + if (tid >= 0) + H5Tclose(tid); + if (sid >= 0) + H5Sclose(sid); return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Dcopy */ @@ -2613,7 +3091,7 @@ Java_hdf_hdf5lib_H5_H5Dcopy // // // Add these methods so that we don't need to call H5Gget_objtype_by_idx -// in a loop to get information for all the object in a group, which takes +// in a loop to get information for all the objects in a group, which takes // a lot of time to finish if the number of objects is more than 10,000 // ///////////////////////////////////////////////////////////////////////////////// @@ -2648,152 +3126,103 @@ typedef struct info_all * Method: H5Gget_obj_info_full * Signature: (JLjava/lang/String;[Ljava/lang/String;[I[I[J[JIII)I */ +/* + * NOTE: This is a dangerous call! The caller can supply any value they'd like + * for 'n' and if it exceeds the number of links in the group, we will most likely + * end up overwriting memory heap-tracking info. + */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1full (JNIEnv *env, jclass clss, jlong loc_id, jstring group_name, jobjectArray objName, jintArray oType, jintArray lType, jlongArray fNo, jlongArray oRef, jint n, jint indx_type, jint indx_order) { - herr_t ret_val = -1; - const char *gName = NULL; - char **oName = NULL; - jboolean isCopy; - jstring str; - jint *otarr; - jint *ltarr; - jlong *refP; - jlong *fnoP; - unsigned long *refs=NULL; - unsigned long *fnos=NULL; - hid_t gid = (hid_t)loc_id; - int i; - int indexType = indx_type; - int indexOrder = indx_order; - - if (oType == NULL) { - h5nullArgument(env, "H5Gget_obj_info_full: oType is NULL"); - } - else if (lType == NULL) { - h5nullArgument(env, "H5Gget_obj_info_full: lType is NULL"); - } - else if (oRef == NULL) { - h5nullArgument(env, "H5Gget_obj_info_full: oRef is NULL"); - } - else if (fNo == NULL) { - h5nullArgument(env, "H5Gget_obj_info_full: fNo is NULL"); + unsigned long *refs = NULL; + unsigned long *fnos = NULL; + const char *gName = NULL; + char **oName = NULL; + jboolean isCopy; + jstring str; + jint *otarr = NULL; + jint *ltarr = NULL; + jlong *refP = NULL; + jlong *fnoP = NULL; + hid_t gid = (hid_t)loc_id; + int i; + int indexType = indx_type; + int indexOrder = indx_order; + herr_t ret_val = FAIL; + + UNUSED(clss); + + if (NULL == oType) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: oType is NULL"); + if (NULL == lType) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: lType is NULL"); + if (NULL == oRef) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: oRef is NULL"); + if (NULL == fNo) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_full: fNo is NULL"); + + PIN_INT_ARRAY(ENVONLY, oType, otarr, &isCopy, "H5Gget_obj_info_full: oType not pinned"); + PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_full: lType not pinned"); + PIN_LONG_ARRAY(ENVONLY, oRef, refP, &isCopy, "H5Gget_obj_info_full: oRef not pinned"); + PIN_LONG_ARRAY(ENVONLY, fNo, fnoP, &isCopy, "H5Gget_obj_info_full: fNo not pinned"); + + if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for object name"); + + if (NULL == (refs = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for ref. info"); + + if (NULL == (fnos = (unsigned long *) HDcalloc((size_t)n, sizeof(unsigned long)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: failed to allocate buffer for file number info"); + + if (group_name) { + PIN_JAVA_STRING(ENVONLY, group_name, gName, &isCopy, "H5Gget_obj_info_full: group_name not pinned"); + + if ((gid = H5Gopen2((hid_t)loc_id, gName, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); } - else { - otarr = ENVPTR->GetIntArrayElements(ENVPAR oType, &isCopy); - if (otarr == NULL) { - h5JNIFatalError(env, "H5Gget_obj_info_full: otype not pinned"); - return -1; - } /* end if */ - ltarr = ENVPTR->GetIntArrayElements(ENVPAR lType, &isCopy); - if (ltarr == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_full: ltype not pinned"); - return -1; - } /* end if */ - refP = ENVPTR->GetLongArrayElements(ENVPAR oRef, &isCopy); - if (refP == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_full: oRef not pinned"); - return -1; - } /* end if */ - fnoP = ENVPTR->GetLongArrayElements(ENVPAR fNo, &isCopy); - if (fnoP == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_full: fNo not pinned"); - return -1; - } /* end if */ - oName = (char **)HDcalloc((size_t)n, sizeof(*oName)); - if (!oName) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_full: oName not allocated"); - return -1; - } /* end if */ - - refs = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); - fnos = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); - if (!refs || !fnos) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); - h5str_array_free(oName, (size_t)n); - if (refs) - HDfree(refs); - if (fnos) - HDfree(fnos); - h5JNIFatalError(env, "H5Gget_obj_info_full: result arrays not allocated"); - return -1; - } /* end if */ - if (group_name != NULL) { - gid = -1; - gName = ENVPTR->GetStringUTFChars(ENVPAR group_name, &isCopy); - if (gName != NULL) { - gid = H5Gopen2((hid_t)loc_id, gName, H5P_DEFAULT); - - ENVPTR->ReleaseStringUTFChars(ENVPAR group_name, gName); - } /* end if */ - if(gid < 0) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); - h5str_array_free(oName, (size_t)n); - HDfree(refs); - HDfree(fnos); - h5JNIFatalError(env, "H5Gget_obj_info_full: could not get group identifier"); - return -1; - } /* end if */ - } /* end if */ + if ((ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, refs, indexType, indexOrder)) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_full: retrieval of object info failed"); - ret_val = H5Gget_obj_info_full(gid, oName, (int *)otarr, (int *)ltarr, fnos, refs, indexType, indexOrder); + for (i = 0; i < n; i++) { + refP[i] = (jlong)refs[i]; + fnoP[i] = (jlong)fnos[i]; - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, 0); + if (oName[i]) { + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, oName[i]))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (group_name != NULL) - H5Gclose(gid); + ENVPTR->SetObjectArrayElement(ENVONLY, objName, i, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - if (ret_val < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR fNo, fnoP, JNI_ABORT); - h5str_array_free(oName, (size_t)n); - HDfree(refs); - HDfree(fnos); - h5libraryError(env); + ENVPTR->DeleteLocalRef(ENVONLY, str); } /* end if */ - else { - for (i=0; iReleaseLongArrayElements(ENVPAR oRef, refP, 0); - - for (i=0; iReleaseLongArrayElements(ENVPAR fNo, fnoP, 0); - - for (i=0; iNewStringUTF(ENVPAR *(oName+i)); - ENVPTR->SetObjectArrayElement(ENVPAR objName, i, (jobject)str); - } /* end if */ - } /* for (i=0; iGetIntArrayElements(ENVPAR oType, &isCopy); - if (otarr == NULL) { - h5JNIFatalError(env, "H5Gget_obj_info_max: otype not pinned"); - return -1; - } /* end if */ + unsigned long *refs = NULL; + jboolean isCopy; + jstring str; + jlong *refP = NULL; + char **oName = NULL; + jint *otarr = NULL; + jint *ltarr = NULL; + int i; + herr_t ret_val = FAIL; - ltarr = ENVPTR->GetIntArrayElements(ENVPAR lType, &isCopy); - if (ltarr == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_max: ltype not pinned"); - return -1; - } /* end if */ + UNUSED(clss); - refP = ENVPTR->GetLongArrayElements(ENVPAR oRef, &isCopy); - if (refP == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_max: oRef not pinned"); - return -1; - } /* end if */ + if (NULL == oType) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: oType is NULL"); + if (NULL == lType) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: lType is NULL"); + if (NULL == oRef) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_obj_info_max: oRef is NULL"); - oName = (char **)HDcalloc((size_t)n, sizeof(*oName)); - if (!oName) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - h5JNIFatalError(env, "H5Gget_obj_info_max: oName not allocated"); - return -1; - } /* end if */ - refs = (unsigned long *)HDcalloc((size_t)n, sizeof(unsigned long)); - if (!refs) { - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, JNI_ABORT); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, JNI_ABORT); - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - h5str_array_free(oName, (size_t)n); - h5JNIFatalError(env, "H5Gget_obj_info_max: result array not allocated"); - return -1; - } /* end if */ + PIN_INT_ARRAY(ENVONLY, oType, otarr, &isCopy, "H5Gget_obj_info_max: oType not pinned"); + PIN_INT_ARRAY(ENVONLY, lType, ltarr, &isCopy, "H5Gget_obj_info_max: lType not pinned"); + PIN_LONG_ARRAY(ENVONLY, oRef, refP, &isCopy, "H5Gget_obj_info_max: oRef not pinned"); - ret_val = H5Gget_obj_info_max((hid_t)loc_id, oName, (int*)otarr, (int*)ltarr, refs, maxnum ); - ENVPTR->ReleaseIntArrayElements(ENVPAR lType, ltarr, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR oType, otarr, 0); + if (NULL == (oName = (char **) HDcalloc((size_t)n, sizeof(*oName)))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5Gget_obj_info_max: failed to allocate buffer for object name"); - if (ret_val < 0) { - ENVPTR->ReleaseLongArrayElements(ENVPAR oRef, refP, JNI_ABORT); - h5str_array_free(oName, (size_t)n); - HDfree(refs); - h5libraryError(env); - } /* end if */ - else { - for (i=0; iReleaseLongArrayElements(ENVPAR oRef, refP, 0); - - for (i=0; iNewStringUTF(ENVPAR *(oName+i)); - ENVPTR->SetObjectArrayElement(ENVPAR objName, i, (jobject)str); - } - } /* for (i=0; iNewStringUTF(ENVONLY, oName[i]))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->SetObjectArrayElement(ENVONLY, objName, i, (jobject)str); + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + ENVPTR->DeleteLocalRef(ENVONLY, str); + } + } /* end for */ + +done: + if (refs) + HDfree(refs); + if (oName) + h5str_array_free(oName, (size_t)n); + if (refP) + UNPIN_LONG_ARRAY(ENVONLY, oRef, refP, (ret_val < 0) ? JNI_ABORT : 0); + if (ltarr) + UNPIN_INT_ARRAY(ENVONLY, lType, ltarr, (ret_val < 0) ? JNI_ABORT : 0); + if (otarr) + UNPIN_INT_ARRAY(ENVONLY, oType, otarr, (ret_val < 0) ? JNI_ABORT : 0); return ret_val; } /* end Java_hdf_hdf5lib_H5_H5Gget_1obj_1info_1max */ @@ -2902,6 +3307,7 @@ H5Gget_obj_info_full (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *fno, unsigned long *objno, int indexType, int indexOrder) { info_all_t info; + info.objname = objname; info.otype = otype; info.ltype = ltype; @@ -2910,11 +3316,22 @@ H5Gget_obj_info_full info.objno = objno; info.count = 0; - if(H5Literate(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { - /* iterate failed, try normal alphabetical order */ - if(H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) + if (H5Literate(loc_id, (H5_index_t)indexType, (H5_iter_order_t)indexOrder, NULL, obj_info_all, (void *)&info) < 0) { + /* + * Reset info stats; most importantly, reset the count. + */ + info.objname = objname; + info.otype = otype; + info.ltype = ltype; + info.idxnum = 0; + info.fno = fno; + info.objno = objno; + info.count = 0; + + /* Iteration failed, try normal alphabetical order */ + if (H5Literate(loc_id, H5_INDEX_NAME, H5_ITER_INC, NULL, obj_info_all, (void *)&info) < 0) return -1; - } /* end if */ + } return info.count; } /* end H5Gget_obj_info_full */ @@ -2924,6 +3341,7 @@ H5Gget_obj_info_max (hid_t loc_id, char **objname, int *otype, int *ltype, unsigned long *objno, long maxnum) { info_all_t info; + info.objname = objname; info.otype = otype; info.ltype = ltype; @@ -2931,7 +3349,7 @@ H5Gget_obj_info_max info.objno = objno; info.count = 0; - if(H5Lvisit(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) + if (H5Lvisit(loc_id, H5_INDEX_NAME, H5_ITER_NATIVE, obj_info_max, (void *)&info) < 0) return -1; return info.count; @@ -2941,75 +3359,87 @@ herr_t obj_info_all (hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) { - int type = -1; - hid_t oid = -1; - herr_t retVal = -1; - info_all_t *datainfo = (info_all_t*)op_data; + info_all_t *datainfo = (info_all_t *)op_data; H5O_info_t object_info; + htri_t object_exists; + size_t str_len; - retVal = H5Oget_info_by_name2(loc_id, name, &object_info, H5O_INFO_ALL, H5P_DEFAULT); + datainfo->otype[datainfo->count] = -1; + datainfo->ltype[datainfo->count] = -1; + datainfo->objno[datainfo->count] = (unsigned long)-1; - if (retVal < 0) { - *(datainfo->otype+datainfo->count) = -1; - *(datainfo->ltype+datainfo->count) = -1; - *(datainfo->objname+datainfo->count) = (char *)HDmalloc(HDstrlen(name)+1); - HDstrcpy(*(datainfo->objname+datainfo->count), name); - *(datainfo->objno+datainfo->count) = (unsigned long)-1; - } /* end if */ - else { - *(datainfo->otype+datainfo->count) = object_info.type; - *(datainfo->ltype+datainfo->count) = info->type; - *(datainfo->objname+datainfo->count) = (char *)HDmalloc(HDstrlen(name)+1); - HDstrcpy(*(datainfo->objname+datainfo->count), name); - - *(datainfo->fno+datainfo->count) = object_info.fileno; - *(datainfo->objno+datainfo->count) = (unsigned long)object_info.addr; - /* - if(info->type==H5L_TYPE_HARD) - *(datainfo->objno+datainfo->count) = (unsigned long)info->u.address; - else - *(datainfo->objno+datainfo->count) = info->u.val_size; - */ - } /* end else */ + str_len = HDstrlen(name); + if (NULL == (datainfo->objname[datainfo->count] = (char *) HDmalloc(str_len + 1))) + goto done; + + HDstrncpy(datainfo->objname[datainfo->count], name, str_len); + (datainfo->objname[datainfo->count])[str_len] = '\0'; + + if ((object_exists = H5Oexists_by_name(loc_id, name, H5P_DEFAULT)) < 0) + goto done; + + if (object_exists) { + if (H5Oget_info_by_name2(loc_id, name, &object_info, H5O_INFO_ALL, H5P_DEFAULT) < 0) + goto done; + + datainfo->otype[datainfo->count] = object_info.type; + datainfo->ltype[datainfo->count] = info->type; + datainfo->fno[datainfo->count] = object_info.fileno; + datainfo->objno[datainfo->count] = (unsigned long)object_info.addr; + } + + /* + if (info->type == H5L_TYPE_HARD) + datainfo->objno[datainfo->count] = (unsigned long)info->u.address; + else + datainfo->objno[datainfo->count] = info->u.val_size; + */ +done: datainfo->count++; - return 0; + return SUCCEED; } /* end obj_info_all */ herr_t obj_info_max (hid_t loc_id, const char *name, const H5L_info_t *info, void *op_data) { - int type = -1; - herr_t retVal = 0; - info_all_t *datainfo = (info_all_t*)op_data; + info_all_t *datainfo = (info_all_t *)op_data; H5O_info_t object_info; + size_t str_len; - retVal = H5Oget_info2(loc_id, &object_info, H5O_INFO_ALL); - if (retVal < 0) { - *(datainfo->otype+datainfo->count) = -1; - *(datainfo->ltype+datainfo->count) = -1; - *(datainfo->objname+datainfo->count) = NULL; - *(datainfo->objno+datainfo->count) = (unsigned long)-1; - return 1; - } /* end if */ - else { - *(datainfo->otype+datainfo->count) = object_info.type; - *(datainfo->ltype+datainfo->count) = info->type; - /* this will be freed by h5str_array_free(oName, n)*/ - *(datainfo->objname+datainfo->count) = (char *)HDmalloc(HDstrlen(name)+1); - strcpy(*(datainfo->objname+datainfo->count), name); - if(info->type==H5L_TYPE_HARD) - *(datainfo->objno+datainfo->count) = (unsigned long)info->u.address; - else - *(datainfo->objno+datainfo->count) = info->u.val_size; - } /* end else */ - datainfo->count++; - if(datainfo->count < (int)datainfo->idxnum) - return 0; + datainfo->otype[datainfo->count] = -1; + datainfo->ltype[datainfo->count] = -1; + datainfo->objname[datainfo->count] = NULL; + datainfo->objno[datainfo->count] = (unsigned long)-1; + + /* This will be freed by h5str_array_free(oName, n) */ + str_len = HDstrlen(name); + if (NULL == (datainfo->objname[datainfo->count] = (char *) HDmalloc(str_len + 1))) + goto done; + + HDstrncpy(datainfo->objname[datainfo->count], name, str_len); + (datainfo->objname[datainfo->count])[str_len] = '\0'; + + if (H5Oget_info2(loc_id, &object_info, H5O_INFO_ALL) < 0) + goto done; + + datainfo->otype[datainfo->count] = object_info.type; + datainfo->ltype[datainfo->count] = info->type; + + if (info->type == H5L_TYPE_HARD) + datainfo->objno[datainfo->count] = (unsigned long)info->u.address; else + datainfo->objno[datainfo->count] = info->u.val_size; + +done: + datainfo->count++; + + if (datainfo->count >= (int)datainfo->idxnum) return 1; + else + return SUCCEED; } /* end obj_info_max */ /* @@ -3021,68 +3451,62 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5export_1dataset (JNIEnv *env, jclass cls, jstring file_export_name, jstring file_name, jstring object_path, jint binary_order) { - herr_t status = -1; - herr_t ret_val = -1; - hid_t file_id = -1; - hid_t dataset_id = -1; + const char *file_export = NULL; + const char *object_name = NULL; + const char *fileName = NULL; + jboolean isCopy; + herr_t ret_val = FAIL; + hid_t file_id = H5I_INVALID_HID; + hid_t dataset_id = H5I_INVALID_HID; FILE *stream; - const char *file_export; - const char *object_name; - const char *fileName; - jboolean isCopy2; - if (file_export_name == NULL) { - h5nullArgument(env, "HDF5Library_export_data: file_export_name is NULL"); - } /* end if */ - else if (object_path == NULL) { - h5nullArgument(env, "HDF5Library_export_data: object_path is NULL"); - } /* end else if */ - else { - PIN_JAVA_STRING(file_name, fileName); - if (fileName != NULL) { - file_id = H5Fopen(fileName, (unsigned)H5F_ACC_RDWR, (hid_t)H5P_DEFAULT); - - UNPIN_JAVA_STRING(file_name, fileName); - - if (file_id < 0) { - /* throw exception */ - h5libraryError(env); - } /* end if */ - else { - object_name = ENVPTR->GetStringUTFChars(ENVPAR object_path, &isCopy2); - if (object_name == NULL) { - h5JNIFatalError( env, "H5Dopen: object name not pinned"); - } /* end if */ - else { - dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT); + UNUSED(cls); - ENVPTR->ReleaseStringUTFChars(ENVPAR object_path, object_name); + if (NULL == file_export_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_export_name is NULL"); - if (dataset_id < 0) { - H5Fclose(file_id); - h5libraryError(env); - } /* end if */ - else { - file_export = ENVPTR->GetStringUTFChars(ENVPAR file_export_name, 0); - stream = HDfopen(file_export, "w+"); - ENVPTR->ReleaseStringUTFChars(ENVPAR file_export_name, file_export); + if (NULL == file_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: file_name is NULL"); - ret_val = h5str_dump_simple_dset(stream, dataset_id, binary_order); + if (NULL == object_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5export_dataset: object_path is NULL"); - if (stream) - HDfclose(stream); + PIN_JAVA_STRING(ENVONLY, file_name, fileName, NULL, "H5export_dataset: file name not pinned"); - H5Dclose(dataset_id); + if ((file_id = H5Fopen(fileName, (unsigned)H5F_ACC_RDWR, (hid_t)H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - H5Fclose(file_id); + PIN_JAVA_STRING(ENVONLY, object_path, object_name, &isCopy, "H5export_dataset: object_path not pinned"); - if (ret_val < 0) - h5libraryError(env); - } /* end else */ - } /* end else */ - } /* end else */ - } - } /* end else */ + if ((dataset_id = H5Dopen2(file_id, object_name, H5P_DEFAULT)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + PIN_JAVA_STRING(ENVONLY, file_export_name, file_export, NULL, "H5export_dataset: file_export name not pinned"); + + if (NULL == (stream = HDfopen(file_export, "w+"))) + H5_JNI_FATAL_ERROR(ENVONLY, "HDfopen failed"); + + if ((ret_val = h5str_dump_simple_dset(ENVONLY, stream, dataset_id, binary_order)) < 0) + H5_JNI_FATAL_ERROR(ENVONLY, "h5str_dump_simple_dset failed"); + + if (stream) { + HDfclose(stream); + stream = NULL; + } + +done: + if (stream) + HDfclose(stream); + if (file_export) + UNPIN_JAVA_STRING(ENVONLY, file_export_name, file_export); + if (object_name) + UNPIN_JAVA_STRING(ENVONLY, object_path, object_name); + if (fileName) + UNPIN_JAVA_STRING(ENVONLY, file_name, fileName); + if (dataset_id >= 0) + H5Dclose(dataset_id); + if (file_id >= 0) + H5Fclose(file_id); } /* end Java_hdf_hdf5lib_H5_H5export_1dataset */ #ifdef __cplusplus diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index 23bc424..e5f0d0b 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -35,18 +35,29 @@ typedef struct h5str_t { size_t max; /* the allocated size of the string */ } h5str_t; -extern void h5str_new (h5str_t *str, size_t len); -extern void h5str_free (h5str_t *str); -extern void h5str_resize (h5str_t *str, size_t new_len); -extern char* h5str_append (h5str_t *str, const char* cstr); -extern size_t h5str_vlsprintf(h5str_t *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data); -extern size_t h5str_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int ptrlen, int expand_data); -extern size_t h5str_vlsconvert(char *str, hid_t container, hid_t tid, hvl_t *buf, int expand_data); -extern size_t h5str_convert(char **str, hid_t container, hid_t tid, hvl_t *buf, int ptroffset, int expand_data); +extern void h5str_new(h5str_t *str, size_t len); +extern void h5str_free(h5str_t *str); +extern void h5str_resize(h5str_t *str, size_t new_len); +extern char* h5str_append(h5str_t *str, const char* cstr); +extern size_t h5str_convert(JNIEnv *env, char **in_str, hid_t container, hid_t tid, void *out_buf, size_t out_buf_offset); +extern size_t h5str_sprintf(JNIEnv *env, h5str_t *out_str, hid_t container, hid_t tid, void *in_buf, size_t in_buf_len, int expand_data); extern void h5str_array_free(char **strs, size_t len); -extern int h5str_dump_simple_dset(FILE *stream, hid_t dset, int binary_order); -extern int h5str_dump_region_blocks_data(h5str_t *str, hid_t region, hid_t region_obj); -extern int h5str_dump_region_points_data(h5str_t *str, hid_t region, hid_t region_obj); +extern int h5str_dump_simple_dset(JNIEnv *env, FILE *stream, hid_t dset, int binary_order); +extern int h5str_dump_region_blocks_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); +extern int h5str_dump_region_points_data(JNIEnv *env, h5str_t *str, hid_t region, hid_t region_obj); + +extern htri_t H5Tdetect_variable_str(hid_t tid); + +/* + * Symbols used to format the output of h5str_sprintf and + * to interpret the input to h5str_convert. + */ +#define H5_COMPOUND_BEGIN_INDICATOR "{" +#define H5_COMPOUND_END_INDICATOR "}" +#define H5_ARRAY_BEGIN_INDICATOR "[" +#define H5_ARRAY_END_INDICATOR "]" +#define H5_VLEN_BEGIN_INDICATOR "(" +#define H5_VLEN_END_INDICATOR ")" /* * Class: hdf_hdf5lib_H5 diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index 89ea703..c816abf 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -21,9 +21,9 @@ extern "C" { #endif /* __cplusplus */ -#include "hdf5.h" #include #include +#include "hdf5.h" #include "h5jni.h" #include "h5vlImp.h" @@ -36,18 +36,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name (JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id) { - hid_t status = -1; - const char *vlName; + const char *volName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(connector_name, vlName); - if (vlName != NULL) { - status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id); + UNUSED(clss); - UNPIN_JAVA_STRING(connector_name, vlName); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLregister_connector_by_name: VOL connector name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5VLregister_connector_by_name(volName, (hid_t)vipl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (volName) + UNPIN_JAVA_STRING(ENVONLY, connector_name, volName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */ @@ -61,11 +62,14 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value (JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id) { - hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id); + hid_t status = H5I_INVALID_HID; + + UNUSED(clss); - if (status < 0) - h5libraryError(env); + if ((status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jlong)status; } /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */ @@ -78,20 +82,21 @@ JNIEXPORT jboolean JNICALL Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered (JNIEnv *env, jclass clss, jobject connector_name) { + const char *volName = NULL; htri_t bval = JNI_FALSE; - const char *vlName; - PIN_JAVA_STRING(connector_name, vlName); - if (vlName != NULL) { - bval = H5VLis_connector_registered(vlName); + UNUSED(clss); - UNPIN_JAVA_STRING(connector_name, vlName); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered: VOL connector name not pinned"); - if (bval > 0) - bval = JNI_TRUE; - else if (bval < 0) - h5libraryError(env); - } + if ((bval = H5VLis_connector_registered(volName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + bval = (bval > 0) ? JNI_TRUE : JNI_FALSE; + +done: + if (volName) + UNPIN_JAVA_STRING(ENVONLY, connector_name, volName); return (jboolean)bval; } /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */ @@ -105,18 +110,19 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1id (JNIEnv *env, jclass clss, jobject connector_name) { - hid_t status = -1; - const char *vlName; + const char *volName = NULL; + hid_t status = H5I_INVALID_HID; - PIN_JAVA_STRING(connector_name, vlName); - if (vlName != NULL) { - status = H5VLget_connector_id(vlName); + UNUSED(clss); - UNPIN_JAVA_STRING(connector_name, vlName); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id: VOL connector name not pinned"); - if (status < 0) - h5libraryError(env); - } + if ((status = H5VLget_connector_id(volName)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + if (volName) + UNPIN_JAVA_STRING(ENVONLY, connector_name, volName); return (jlong)status; } /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */ @@ -131,41 +137,31 @@ JNIEXPORT jobject JNICALL Java_hdf_hdf5lib_H5_H5VLget_1connector_1name (JNIEnv *env, jclass clss, jlong object_id) { - char *vlName; - ssize_t buf_size; - ssize_t status; + ssize_t buf_size, status; + char *volName = NULL; jstring str = NULL; - /* get the length of the comment */ - buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0); - if (buf_size < 0) { - H5Eprint2(H5E_DEFAULT, NULL); - - h5badArgument(env, "H5VLget_connector_name: buf_size < 0"); - } /* end if */ - else if (buf_size > 0) { - buf_size++; /* add extra space for the null terminator */ - vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); - if (vlName == NULL) { - /* exception -- out of memory */ - h5outOfMemory(env, "H5VLget_connector_name: malloc failed"); - } /* end if */ - else { - status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size); - - if (status < 0) { - h5libraryError(env); - } /* end if */ - else { - /* may throw OutOfMemoryError */ - str = ENVPTR->NewStringUTF(ENVPAR vlName); - if (str == NULL) { - h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated"); - } /* end if */ - } /* end else */ - HDfree(vlName); - } - } /* end else if */ + UNUSED(clss); + + /* Get the length of the comment */ + if ((buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + + if (buf_size > 0) { + if (NULL == (volName = (char *) HDmalloc(sizeof(char) * (size_t)buf_size + 1))) + H5_JNI_FATAL_ERROR(ENVONLY, "H5VLget_connector_name: failed to allocated VOL connector name buffer"); + + if ((status = H5VLget_connector_name((hid_t)object_id, volName, (size_t)buf_size + 1)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + volName[buf_size] = '\0'; + + if (NULL == (str = ENVPTR->NewStringUTF(ENVONLY, volName))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + } + +done: + if (volName) + HDfree(volName); return (jstring)str; } /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */ @@ -179,10 +175,15 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLclose (JNIEnv *env, jclass clss, jlong connector_id) { - herr_t retValue = H5VLclose((hid_t)connector_id); + herr_t retValue = FAIL; + + UNUSED(clss); + + if ((retValue = H5VLclose((hid_t)connector_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retValue < 0) - h5libraryError(env); +done: + return; } /* end Java_hdf_hdf5lib_H5_H5VLclose */ /* @@ -194,10 +195,15 @@ JNIEXPORT void JNICALL Java_hdf_hdf5lib_H5_H5VLunregister_1connector (JNIEnv *env, jclass clss, jlong connector_id) { - herr_t retValue = H5VLunregister_connector((hid_t)connector_id); + herr_t retValue = FAIL; + + UNUSED(clss); + + if ((retValue = H5VLunregister_connector((hid_t)connector_id)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - if (retValue < 0) - h5libraryError(env); +done: + return; } /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h index af824a9..207efa5 100644 --- a/java/src/jni/h5vlImp.h +++ b/java/src/jni/h5vlImp.h @@ -44,7 +44,7 @@ Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value * Signature: (Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL -Java_hdf_hdf5lib_H5_H5VLis_connector_registered +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered (JNIEnv *, jclass, jobject); /* diff --git a/java/src/jni/h5zImp.c b/java/src/jni/h5zImp.c index a5e6cd8..a1c8517 100644 --- a/java/src/jni/h5zImp.c +++ b/java/src/jni/h5zImp.c @@ -36,12 +36,15 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zunregister (JNIEnv *env, jclass clss, jint filter) { - herr_t retValue = H5Zunregister((H5Z_filter_t)filter); + herr_t retVal = FAIL; - if (retValue < 0) - h5libraryError(env); + UNUSED(clss); - return (jint)retValue; + if ((retVal = H5Zunregister((H5Z_filter_t)filter)) < 0) + H5_LIBRARY_ERROR(ENVONLY); + +done: + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Zunregister */ /* @@ -53,12 +56,15 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Zfilter_1avail (JNIEnv *env, jclass clss, jint filter) { - herr_t retValue = H5Zfilter_avail((H5Z_filter_t)filter); + herr_t retVal = FAIL; + + UNUSED(clss); - if (retValue < 0) - h5libraryError(env); + if ((retVal = H5Zfilter_avail((H5Z_filter_t)filter)) < 0) + H5_LIBRARY_ERROR(ENVONLY); - return (jint)retValue; +done: + return (jint)retVal; } /* end Java_hdf_hdf5lib_H5_H5Zfilter_1avail */ /* @@ -73,9 +79,12 @@ Java_hdf_hdf5lib_H5_H5Zget_1filter_1info { unsigned int flags = 0; - if (H5Zget_filter_info ((H5Z_filter_t) filter, (unsigned *) &flags) < 0) - h5libraryError(env); + UNUSED(clss); + + if (H5Zget_filter_info((H5Z_filter_t) filter, (unsigned *) &flags) < 0) + H5_LIBRARY_ERROR(ENVONLY); +done: return (jint)flags; } /* end Java_hdf_hdf5lib_H5_H5Zget_1filter_1info */ diff --git a/java/src/jni/nativeData.c b/java/src/jni/nativeData.c index 33f4953..947f843 100644 --- a/java/src/jni/nativeData.c +++ b/java/src/jni/nativeData.c @@ -50,54 +50,49 @@ JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jbyte *barr; - jintArray rarray = NULL; - int blen; - jint *iarray; - jboolean bb; - char *bp; - jint *iap; - int ii; - int len; - - if (bdata == NULL) { - h5nullArgument( env, "byteToInt: bdata is NULL?"); - } /* end if */ - else { - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToInt: pin failed"); - } /* end if */ - else { - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - - len = blen/(int)sizeof(jint); - rarray = ENVPTR->NewIntArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToInt" ); - return NULL; - } /* end if */ - - iarray = ENVPTR->GetIntArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToInt: pin iarray failed"); - return NULL; - } /* end if */ - - bp = (char *)barr; - iap = iarray; - for (ii = 0; ii < len; ii++) { - *iap = *(jint *)bp; - iap++; - bp += sizeof(jint); - } /* end for */ - - ENVPTR->ReleaseIntArrayElements(ENVPAR rarray,iarray, 0); - } /* end else */ - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - } /* end else */ + jintArray rarray = NULL; + jboolean bb; + jbyte *barr = NULL; + jint *iarray = NULL; + jint *iap = NULL; + char *bp = NULL; + int blen; + int ii; + int len; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToInt: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToInt: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: bdata length < 0"); + } + + len = blen / (int)sizeof(jint); + + if (NULL == (rarray = ENVPTR->NewIntArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_INT_ARRAY(ENVONLY, rarray, iarray, &bb, "byteToInt: int array not pinned"); + + bp = (char *)barr; + iap = iarray; + for (ii = 0; ii < len; ii++) { + *iap = *(jint *)bp; + iap++; + bp += sizeof(jint); + } /* end for */ + +done: + if (iarray) + UNPIN_INT_ARRAY(ENVONLY, rarray, iarray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); + return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToInt___3B */ @@ -106,40 +101,34 @@ JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jbyte *barr; - jfloatArray rarray; - int blen; - jfloat *farray; - jboolean bb; - char *bp; - jfloat *iap; - int ii; - int len; - - if (bdata == NULL) { - h5nullArgument( env, "byteToFloat: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToFloat: pin failed"); - return NULL; - } /* end if */ - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - - len = blen/(int)sizeof(jfloat); - rarray = ENVPTR->NewFloatArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToFloat" ); - return NULL; - } /* end if */ - farray = ENVPTR->GetFloatArrayElements(ENVPAR rarray,&bb); - if (farray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToFloat: pin farray failed"); - return NULL; - } /* end if */ + jfloatArray rarray; + jboolean bb; + jfloat *farray = NULL; + jfloat *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + int len; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); + } + + len = blen / (int)sizeof(jfloat); + + if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); bp = (char *)barr; iap = farray; @@ -149,8 +138,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B bp += sizeof(jfloat); } /* end for */ - ENVPTR->ReleaseFloatArrayElements(ENVPAR rarray,farray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (farray) + UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat___3B */ @@ -160,42 +152,34 @@ JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jbyte *barr; - jshortArray rarray; - int blen; - jshort *sarray; - jboolean bb; - char *bp; - jshort *iap; - int ii; - int len; - - if (bdata == NULL) { - h5nullArgument( env, "byteToShort: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToShort: pin failed"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - - len = blen/(int)sizeof(jshort); - rarray = ENVPTR->NewShortArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToShort" ); - return NULL; - } /* end if */ - - sarray = ENVPTR->GetShortArrayElements(ENVPAR rarray,&bb); - if (sarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToShort: pin sarray failed"); - return NULL; - } /* end if */ + jshortArray rarray; + jboolean bb; + jshort *sarray = NULL; + jshort *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + int len; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToShort: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToShort: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: bdata length < 0"); + } + + len = blen / (int)sizeof(jshort); + + if (NULL == (rarray = ENVPTR->NewShortArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_SHORT_ARRAY(ENVONLY, rarray, sarray, &bb, "byteToShort: short array not pinned"); bp = (char *)barr; iap = sarray; @@ -205,53 +189,48 @@ Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B bp += sizeof(jshort); } /* end for */ - ENVPTR->ReleaseShortArrayElements(ENVPAR rarray,sarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (sarray) + UNPIN_SHORT_ARRAY(ENVONLY, rarray, sarray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToShort___3B */ - /* returns long [] */ JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jbyte *barr; - jlongArray rarray; - int blen; - jlong *larray; - jboolean bb; - char *bp; - jlong *iap; - int ii; - int len; - - if (bdata == NULL) { - h5nullArgument( env, "byteToLong: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToLong: pin failed"); - return NULL; - } /* end if */ - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - - len = blen/(int)sizeof(jlong); - rarray = ENVPTR->NewLongArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToLong" ); - return NULL; - } /* end if */ - - larray = ENVPTR->GetLongArrayElements(ENVPAR rarray,&bb); - if (larray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToLong: pin larray failed"); - return NULL; - } /* end if */ + jlongArray rarray; + jboolean bb; + jlong *larray = NULL; + jlong *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + int len; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToLong: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToLong: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: bdata length < 0"); + } + + len = blen / (int)sizeof(jlong); + + if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); bp = (char *)barr; iap = larray; @@ -260,53 +239,49 @@ Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B iap++; bp += sizeof(jlong); } /* end for */ - ENVPTR->ReleaseLongArrayElements(ENVPAR rarray,larray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); + +done: + if (larray) + UNPIN_LONG_ARRAY(ENVONLY, rarray, larray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong___3B */ - /* returns double [] */ JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B (JNIEnv *env, jclass clss, jbyteArray bdata) /* IN: array of bytes */ { - jbyte *barr; - jdoubleArray rarray; - int blen; - jdouble *darray; - jboolean bb; - char *bp; - jdouble *iap; - int ii; - int len; - - if (bdata == NULL) { - h5nullArgument( env, "byteToDouble: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToDouble: pin failed"); - return NULL; - } /* end if */ - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - - len = blen/(int)sizeof(jdouble); - rarray = ENVPTR->NewDoubleArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToDouble" ); - return NULL; - } /* end if */ - - darray = ENVPTR->GetDoubleArrayElements(ENVPAR rarray,&bb); - if (darray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToDouble: pin darray failed"); - return NULL; - } /* end if */ + jdoubleArray rarray; + jboolean bb; + jdouble *darray = NULL; + jdouble *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + int len; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToDouble: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToDouble: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: bdata length < 0"); + } + + len = blen / (int)sizeof(jdouble); + + if (NULL == (rarray = ENVPTR->NewDoubleArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, &bb, "byteToDouble: double array not pinned"); bp = (char *)barr; iap = darray; @@ -316,59 +291,50 @@ Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B bp += sizeof(jdouble); } /* end for */ - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rarray,darray,0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (darray) + UNPIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToDouble___3B */ - /* returns int [] */ JNIEXPORT jintArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - char *bp; - jbyte *barr; - jintArray rarray; - int blen; - jint *iarray; - jint *iap; - int ii; - jboolean bb; - - if (bdata == NULL) { - h5nullArgument( env, "byteToInt: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError(env, "byteToInt: pin failed"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - if ((start < 0) || ((int)(start + (len*(int)sizeof(jint))) > blen)) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToInt: getLen failed"); - return NULL; - } /* end if */ + jintArray rarray; + jboolean bb; + jint *iarray = NULL; + jint *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToInt: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToInt: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToInt: bdata length < 0"); + } + + if ((start < 0) || ((int)(start + (len * (int)sizeof(jint))) > blen)) + H5_JNI_FATAL_ERROR(ENVONLY, "byteToInt: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; - rarray = ENVPTR->NewIntArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToInt" ); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewIntArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - iarray = ENVPTR->GetIntArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError(env, "byteToInt: pin iarray failed"); - return NULL; - } /* end if */ + PIN_INT_ARRAY(ENVONLY, rarray, iarray, &bb, "byteToInt: int array not pinned"); iap = iarray; for (ii = 0; ii < len; ii++) { @@ -377,8 +343,11 @@ Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B bp += sizeof(jint); } /* end for */ - ENVPTR->ReleaseIntArrayElements(ENVPAR rarray,iarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (iarray) + UNPIN_INT_ARRAY(ENVONLY, rarray, iarray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToInt__II_3B */ @@ -388,57 +357,49 @@ JNIEXPORT jshortArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - char *bp; - jbyte *barr; - jshortArray rarray; - int blen; - jshort *iarray; - jshort *iap; - int ii; - jboolean bb; - - if (bdata == NULL) { - h5nullArgument( env, "byteToShort: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError( env, "byteToShort: getByte failed?"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - if ((start < 0) || ((int)(start + (len*(int)sizeof(jshort))) > blen)) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5badArgument( env, "byteToShort: start or len is out of bounds"); - return NULL; - } /* end if */ + jshortArray rarray; + jboolean bb; + jshort *sarray = NULL; + jshort *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToShort: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToShort: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToShort: bdata length < 0"); + } + + if ((start < 0) || ((int)(start + (len * (int)sizeof(jshort))) > blen)) + H5_JNI_FATAL_ERROR(ENVONLY, "byteToShort: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; - rarray = ENVPTR->NewShortArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToShort" ); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewShortArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - iarray = ENVPTR->GetShortArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError( env, "byteToShort: getShort failed?"); - return NULL; - } /* end if */ + PIN_SHORT_ARRAY(ENVONLY, rarray, sarray, &bb, "byteToShort: short array not pinned"); - iap = iarray; + iap = sarray; for (ii = 0; ii < len; ii++) { *iap = *(jshort *)bp; iap++; bp += sizeof(jshort); } /* end for */ - ENVPTR->ReleaseShortArrayElements(ENVPAR rarray,iarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (sarray) + UNPIN_SHORT_ARRAY(ENVONLY, rarray, sarray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToShort__II_3B */ @@ -448,57 +409,49 @@ JNIEXPORT jfloatArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - char *bp; - jbyte *barr; - jfloatArray rarray; - int blen; - jfloat *iarray; - jfloat *iap; - int ii; - jboolean bb; - - if (bdata == NULL) { - h5nullArgument( env, "byteToFloat: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError( env, "byteToFloat: getByte failed?"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - if ((start < 0) || ((int)(start + (len*(int)sizeof(jfloat))) > blen)) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5badArgument( env, "byteToFloat: start or len is out of bounds"); - return NULL; - } /* end if */ + jfloatArray rarray; + jboolean bb; + jfloat *farray = NULL; + jfloat *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToFloat: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToFloat: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToFloat: bdata length < 0"); + } + + if ((start < 0) || ((int)(start + (len * (int)sizeof(jfloat))) > blen)) + H5_JNI_FATAL_ERROR(ENVONLY, "byteToFloat: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; - rarray = ENVPTR->NewFloatArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToFloat" ); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewFloatArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - iarray = ENVPTR->GetFloatArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError( env, "byteToFloat: getFloat failed?"); - return NULL; - } /* end if */ + PIN_FLOAT_ARRAY(ENVONLY, rarray, farray, &bb, "byteToFloat: float array not pinned"); - iap = iarray; + iap = farray; for (ii = 0; ii < len; ii++) { *iap = *(jfloat *)bp; iap++; bp += sizeof(jfloat); } /* end for */ - ENVPTR->ReleaseFloatArrayElements(ENVPAR rarray,iarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (farray) + UNPIN_FLOAT_ARRAY(ENVONLY, rarray, farray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToFloat__II_3B */ @@ -508,58 +461,49 @@ JNIEXPORT jlongArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - char *bp; - jbyte *barr; - jlongArray rarray; - int blen; - jlong *iarray; - jlong *iap; - int ii; - jboolean bb; - - if (bdata == NULL) { - h5nullArgument( env, "byteToLong: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError( env, "byteToLong: getByte failed?"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - if ((start < 0) || ((int)(start + (len*(int)sizeof(jlong))) > blen)) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5badArgument( env, "byteToLong: start or len is out of bounds"); - return NULL; - } /* end if */ + jlongArray rarray; + jboolean bb; + jlong *larray = NULL; + jlong *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToLong: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToLong: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToLong: bdata length < 0"); + } + + if ((start < 0) || ((int)(start + (len * (int)sizeof(jlong))) > blen)) + H5_JNI_FATAL_ERROR(ENVONLY, "byteToLong: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; - rarray = ENVPTR->NewLongArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToLong" ); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewLongArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - iarray = ENVPTR->GetLongArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError( env, "byteToLong: getLong failed?"); - return NULL; - } /* end if */ + PIN_LONG_ARRAY(ENVONLY, rarray, larray, &bb, "byteToLong: long array not pinned"); - iap = iarray; + iap = larray; for (ii = 0; ii < len; ii++) { - *iap = *(jlong *)bp; iap++; bp += sizeof(jlong); } /* end for */ - ENVPTR->ReleaseLongArrayElements(ENVPAR rarray,iarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (larray) + UNPIN_LONG_ARRAY(ENVONLY, rarray, larray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToLong__II_3B */ @@ -569,57 +513,49 @@ JNIEXPORT jdoubleArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B (JNIEnv *env, jclass clss, jint start, jint len, jbyteArray bdata) /* IN: array of bytes */ { - char *bp; - jbyte *barr; - jdoubleArray rarray; - int blen; - jdouble *iarray; - jdouble *iap; - int ii; - jboolean bb; - - if (bdata == NULL) { - h5nullArgument( env, "byteToDouble: bdata is NULL?"); - return NULL; - } /* end if */ - barr = ENVPTR->GetByteArrayElements(ENVPAR bdata,&bb); - if (barr == NULL) { - h5JNIFatalError( env, "byteToDouble: getByte failed?"); - return NULL; - } /* end if */ - - blen = ENVPTR->GetArrayLength(ENVPAR bdata); - if ((start < 0) || ((int)(start + (len*(int)sizeof(jdouble))) > blen)) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5badArgument( env, "byteToDouble: start or len is out of bounds"); - return NULL; - } /* end if */ + jdoubleArray rarray; + jboolean bb; + jdouble *darray = NULL; + jdouble *iap = NULL; + jbyte *barr = NULL; + char *bp = NULL; + int blen; + int ii; + + UNUSED(clss); + + if (NULL == bdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "byteToDouble: byte array is NULL"); + + PIN_BYTE_ARRAY(ENVONLY, bdata, barr, &bb, "byteToDouble: byte array not pinned"); + + if ((blen = ENVPTR->GetArrayLength(ENVONLY, bdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "byteToDouble: bdata length < 0"); + } + + if ((start < 0) || ((int)(start + (len * (int)sizeof(jdouble))) > blen)) + H5_JNI_FATAL_ERROR(ENVONLY, "byteToDouble: start < 0 or len exceeded buffer length"); bp = (char *)barr + start; - rarray = ENVPTR->NewDoubleArray(ENVPAR len); - if (rarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5outOfMemory( env, "byteToDouble" ); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewDoubleArray(ENVONLY, len))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - iarray = ENVPTR->GetDoubleArrayElements(ENVPAR rarray,&bb); - if (iarray == NULL) { - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); - h5JNIFatalError( env, "byteToDouble: getDouble failed?"); - return NULL; - } /* end if */ + PIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, &bb, "byteToDouble: double array not pinned"); - iap = iarray; + iap = darray; for (ii = 0; ii < len; ii++) { *iap = *(jdouble *)bp; iap++; bp += sizeof(jdouble); } /* end for */ - ENVPTR->ReleaseDoubleArrayElements(ENVPAR rarray,iarray, 0); - ENVPTR->ReleaseByteArrayElements(ENVPAR bdata,barr,JNI_ABORT); +done: + if (darray) + UNPIN_DOUBLE_ARRAY(ENVONLY, rarray, darray, rarray ? 0 : JNI_ABORT); + if (barr) + UNPIN_BYTE_ARRAY(ENVONLY, bdata, barr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToDouble__II_3B */ @@ -629,67 +565,59 @@ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I (JNIEnv *env, jclass clss, jint start, jint len, jintArray idata) /* IN: array of int */ { - jint *ip; - jint *iarr; - int ilen; - jbyteArray rarray; - int blen; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ii; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + jint *ip = NULL; + jint *iarr = NULL; + int ilen; + int blen; + int ii; + int ij; union things { int ival; char bytes[4]; } u; - if (idata == NULL) { - h5nullArgument( env, "intToByte: idata is NULL?"); - return NULL; - } /* end if */ + UNUSED(clss); + + if (NULL == idata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "intToByte: int array is NULL"); - iarr = ENVPTR->GetIntArrayElements(ENVPAR idata,&bb); - if (iarr == NULL) { - h5JNIFatalError( env, "intToByte: getInt failed?"); - return NULL; - } /* end if */ + PIN_INT_ARRAY(ENVONLY, idata, iarr, &bb, "intToByte: int array not pinned"); - ilen = ENVPTR->GetArrayLength(ENVPAR idata); - if ((start < 0) || (((start + len)) > ilen)) { - ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5badArgument( env, "intToByte: start or len is out of bounds"); - return NULL; - } /* end if */ + if ((ilen = ENVPTR->GetArrayLength(ENVONLY, idata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "intToByte: idata length < 0"); + } + + if ((start < 0) || (((start + len)) > ilen)) + H5_JNI_FATAL_ERROR(ENVONLY, "intToByte: start < 0 or len exceeded buffer length"); ip = iarr + start; blen = ilen * (int)sizeof(jint); - rarray = ENVPTR->NewByteArray(ENVPAR blen); - if (rarray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5outOfMemory( env, "intToByte" ); - return NULL; - } /* end if */ - - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5JNIFatalError( env, "intToByte: getByte failed?"); - return NULL; - } /* end if */ + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, blen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "intToByte: byte array not pinned"); bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; ij < sizeof(jint); ij++) { + for (ij = 0; (size_t) ij < sizeof(jint); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); - ENVPTR->ReleaseIntArrayElements(ENVPAR idata,iarr,JNI_ABORT); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, rarray ? 0 : JNI_ABORT); + if (iarr) + UNPIN_INT_ARRAY(ENVONLY, idata, iarr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I */ @@ -697,68 +625,61 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__II_3I /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S - (JNIEnv *env, jclass clss, jint start, jint len, jshortArray idata) /* IN: array of short */ + (JNIEnv *env, jclass clss, jint start, jint len, jshortArray sdata) /* IN: array of short */ { - jshort *ip; - jshort *iarr; - int ilen; - jbyteArray rarray; - int blen; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ii; - int ij; + jbyteArray rarray; + jboolean bb; + jshort *ip = NULL; + jshort *sarr = NULL; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { short ival; char bytes[4]; } u; - if (idata == NULL) { - h5nullArgument( env, "shortToByte: idata is NULL?"); - return NULL; - } /* end if */ - iarr = ENVPTR->GetShortArrayElements(ENVPAR idata,&bb); - if (iarr == NULL) { - h5JNIFatalError( env, "shortToByte: getShort failed?"); - return NULL; - } /* end if */ - - ilen = ENVPTR->GetArrayLength(ENVPAR idata); - if ((start < 0) || (((start + len)) > ilen)) { - ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5badArgument( env, "shortToByte: start or len is out of bounds"); - return NULL; - } /* end if */ + UNUSED(clss); - ip = iarr + start; + if (NULL == sdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "shortToByte: short array is NULL"); + + PIN_SHORT_ARRAY(ENVONLY, sdata, sarr, &bb, "shortToByte: short array not pinned"); + + if ((ilen = ENVPTR->GetArrayLength(ENVONLY, sdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "shortToByte: sdata length < 0"); + } + + if ((start < 0) || (((start + len)) > ilen)) + H5_JNI_FATAL_ERROR(ENVONLY, "shortToByte: start < 0 or len exceeded buffer length"); + + ip = sarr + start; blen = ilen * (int)sizeof(jshort); - rarray = ENVPTR->NewByteArray(ENVPAR blen); - if (rarray == NULL) { - ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5outOfMemory( env, "shortToByte" ); - return NULL; - } /* end if */ - - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5JNIFatalError( env, "shortToByte: getByte failed?"); - return NULL; - } /* end if */ + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, blen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "shortToByte: byte array not pinned"); bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; ij < sizeof(jshort); ij++) { + for (ij = 0; (size_t) ij < sizeof(jshort); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); - ENVPTR->ReleaseShortArrayElements(ENVPAR idata,iarr,JNI_ABORT); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, rarray ? 0 : JNI_ABORT); + if (sarr) + UNPIN_SHORT_ARRAY(ENVONLY, sdata, sarr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S */ @@ -766,68 +687,61 @@ Java_hdf_hdf5lib_HDFNativeData_shortToByte__II_3S /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F - (JNIEnv *env, jclass clss, jint start, jint len, jfloatArray idata) /* IN: array of float */ + (JNIEnv *env, jclass clss, jint start, jint len, jfloatArray fdata) /* IN: array of float */ { - jfloat *ip; - jfloat *iarr; - int ilen; - jbyteArray rarray; - int blen; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ii; - int ij; + jbyteArray rarray; + jboolean bb; + jfloat *ip = NULL; + jfloat *farr = NULL; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { float ival; char bytes[4]; } u; - if (idata == NULL) { - h5nullArgument( env, "floatToByte: idata is NULL?"); - return NULL; - } /* end if */ - iarr = ENVPTR->GetFloatArrayElements(ENVPAR idata,&bb); - if (iarr == NULL) { - h5JNIFatalError( env, "floatToByte: getFloat failed?"); - return NULL; - } /* end if */ - - ilen = ENVPTR->GetArrayLength(ENVPAR idata); - if ((start < 0) || (((start + len)) > ilen)) { - ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5badArgument( env, "floatToByte: start or len is out of bounds"); - return NULL; - } /* end if */ + UNUSED(clss); - ip = iarr + start; + if (NULL == fdata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "floatToByte: float array is NULL"); + + PIN_FLOAT_ARRAY(ENVONLY, fdata, farr, &bb, "floatToByte: float array not pinned"); + + if ((ilen = ENVPTR->GetArrayLength(ENVONLY, fdata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "floatToByte: fdata length < 0"); + } + + if ((start < 0) || (((start + len)) > ilen)) + H5_JNI_FATAL_ERROR(ENVONLY, "floatToByte: start < 0 or len exceeded buffer length"); + + ip = farr + start; blen = ilen * (int)sizeof(jfloat); - rarray = ENVPTR->NewByteArray(ENVPAR blen); - if (rarray == NULL) { - ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5outOfMemory( env, "floatToByte" ); - return NULL; - } /* end if */ - - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5JNIFatalError( env, "floatToByte: getByte failed?"); - return NULL; - } /* end if */ + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, blen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "floatToByte: byte array not pinned"); bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; ij < sizeof(jfloat); ij++) { + for (ij = 0; (size_t) ij < sizeof(jfloat); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); - ENVPTR->ReleaseFloatArrayElements(ENVPAR idata,iarr,JNI_ABORT); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, rarray ? 0 : JNI_ABORT); + if (farr) + UNPIN_FLOAT_ARRAY(ENVONLY, fdata, farr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F */ @@ -835,178 +749,159 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__II_3F /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D - (JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray idata) /* IN: array of double */ + (JNIEnv *env, jclass clss, jint start, jint len, jdoubleArray ddata) /* IN: array of double */ { - jdouble *ip; - jdouble *iarr; - int ilen; - jbyteArray rarray; - int blen; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ii; - int ij; + jbyteArray rarray; + jboolean bb; + jdouble *ip = NULL; + jdouble *darr = NULL; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { double ival; char bytes[8]; } u; - if (idata == NULL) { - h5nullArgument( env, "doubleToByte: idata is NULL?"); - return NULL; - } /* end if */ - iarr = ENVPTR->GetDoubleArrayElements(ENVPAR idata,&bb); - if (iarr == NULL) { - h5JNIFatalError( env, "doubleToByte: getDouble failed?"); - return NULL; - } /* end if */ - - ilen = ENVPTR->GetArrayLength(ENVPAR idata); - if ((start < 0) || (((start + len)) > ilen)) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5badArgument( env, "doubleToByte: start or len is out of bounds"); - return NULL; - } /* end if */ + UNUSED(clss); - ip = iarr + start; + if (NULL == ddata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "doubleToByte: double array is NULL"); + + PIN_DOUBLE_ARRAY(ENVONLY, ddata, darr, &bb, "doubleToByte: double array not pinned"); + + if ((ilen = ENVPTR->GetArrayLength(ENVONLY, ddata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "doubleToByte: ddata length < 0"); + } + + if ((start < 0) || (((start + len)) > ilen)) + H5_JNI_FATAL_ERROR(ENVONLY, "doubleToByte: start < 0 or len exceeded buffer length"); + + ip = darr + start; blen = ilen * (int)sizeof(jdouble); - rarray = ENVPTR->NewByteArray(ENVPAR blen); - if (rarray == NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5outOfMemory( env, "doubleToByte" ); - return NULL; - } /* end if */ - - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5JNIFatalError( env, "doubleToByte: getByte failed?"); - return NULL; - } /* end if */ + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, blen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "doubleToByte: byte array not pinned"); bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; ij < sizeof(jdouble); ij++) { + for (ij = 0; (size_t) ij < sizeof(jdouble); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); - ENVPTR->ReleaseDoubleArrayElements(ENVPAR idata,iarr,JNI_ABORT); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, rarray ? 0 : JNI_ABORT); + if (darr) + UNPIN_DOUBLE_ARRAY(ENVONLY, ddata, darr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_doubleToByte__II_3D */ - /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J - (JNIEnv *env, jclass clss, jint start, jint len, jlongArray idata) /* IN: array of long */ + (JNIEnv *env, jclass clss, jint start, jint len, jlongArray ldata) /* IN: array of long */ { - jlong *ip; - jlong *iarr; - int ilen; - jbyteArray rarray; - int blen; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ii; - int ij; + jbyteArray rarray; + jboolean bb; + jlong *ip = NULL; + jlong *larr = NULL; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ilen; + int blen; + int ii; + int ij; union things { jlong ival; char bytes[8]; } u; - if (idata == NULL) { - h5nullArgument( env, "longToByte: idata is NULL?"); - return NULL; - } /* end if */ - iarr = ENVPTR->GetLongArrayElements(ENVPAR idata,&bb); - if (iarr == NULL) { - h5JNIFatalError( env, "longToByte: getLong failed?"); - return NULL; - } /* end if */ - - ilen = ENVPTR->GetArrayLength(ENVPAR idata); - if ((start < 0) || (((start + len)) > ilen)) { - ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5badArgument( env, "longToByte: start or len is out of bounds?\n"); - return NULL; - } /* end if */ + UNUSED(clss); - ip = iarr + start; + if (NULL == ldata) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "longToByte: long array is NULL"); + + PIN_LONG_ARRAY(ENVONLY, ldata, larr, &bb, "longToByte: long array not pinned"); + + if ((ilen = ENVPTR->GetArrayLength(ENVONLY, ldata)) < 0) { + CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "longToByte: ldata length < 0"); + } + + if ((start < 0) || (((start + len)) > ilen)) + H5_JNI_FATAL_ERROR(ENVONLY, "longToByte: start < 0 or len exceeded buffer length"); + + ip = larr + start; blen = ilen * (int)sizeof(jlong); - rarray = ENVPTR->NewByteArray(ENVPAR blen); - if (rarray == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5outOfMemory( env, "longToByte" ); - return NULL; - } /* end if */ - - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); - h5JNIFatalError( env, "longToByte: getByte failed?"); - return NULL; - } /* end if */ + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, blen))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "longToByte: byte array not pinned"); bap = barray; for (ii = 0; ii < len; ii++) { u.ival = *ip++; - for (ij = 0; ij < sizeof(jlong); ij++) { + for (ij = 0; (size_t) ij < sizeof(jlong); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); - ENVPTR->ReleaseLongArrayElements(ENVPAR idata,iarr,JNI_ABORT); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, rarray ? 0 : JNI_ABORT); + if (larr) + UNPIN_LONG_ARRAY(ENVONLY, ldata, larr, JNI_ABORT); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_longToByte__II_3J */ - /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_intToByte__I (JNIEnv *env, jclass clss, jint idata) /* IN: int */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - int ij; - jboolean bb; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { int ival; char bytes[sizeof(int)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jint)); - if (rarray == NULL) { - h5outOfMemory( env, "intToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jint)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "intToByte: getByte failed?"); - return NULL; - } /* end if */ + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "intToByte: byte array not pinned"); bap = barray; u.ival = idata; - for (ij = 0; ij < sizeof(jint); ij++) { + for (ij = 0; (size_t) ij < sizeof(jint); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_intToByte__I */ @@ -1014,38 +909,35 @@ Java_hdf_hdf5lib_HDFNativeData_intToByte__I /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_floatToByte__F - (JNIEnv *env, jclass clss, jfloat idata) /* IN: int */ + (JNIEnv *env, jclass clss, jfloat fdata) /* IN: float */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { float ival; char bytes[sizeof(float)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jfloat)); - if (rarray == NULL) { - h5outOfMemory( env, "floatToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "floatToByte: getByte failed?"); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jfloat)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "floatToByte: byte array not pinned"); bap = barray; - u.ival = idata; - for (ij = 0; ij < sizeof(jfloat); ij++) { + u.ival = fdata; + for (ij = 0; (size_t) ij < sizeof(jfloat); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_floatToByte__F */ @@ -1053,118 +945,107 @@ Java_hdf_hdf5lib_HDFNativeData_floatToByte__F /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_shortToByte__S - (JNIEnv *env, jclass clss, jshort idata) /* IN: short */ + (JNIEnv *env, jclass clss, jshort sdata) /* IN: short */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { short ival; char bytes[sizeof(short)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jshort)); - if (rarray == NULL) { - h5outOfMemory( env, "shortToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "shortToByte: getShort failed?"); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jshort)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "shortToByte: byte array not pinned"); bap = barray; - u.ival = idata; - for (ij = 0; ij < sizeof(jshort); ij++) { + u.ival = sdata; + for (ij = 0; (size_t) ij < sizeof(jshort); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_shortToByte__S */ - /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D - (JNIEnv *env, jclass clss, jdouble idata) /* IN: double */ + (JNIEnv *env, jclass clss, jdouble ddata) /* IN: double */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { double ival; char bytes[sizeof(double)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jdouble)); - if (rarray == NULL) { - h5outOfMemory( env, "doubleToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); + + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jdouble)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "doubleToByte: getDouble failed?"); - return NULL; - } /* end if */ + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "doubleToByte: byte array not pinned"); bap = barray; - u.ival = idata; - for (ij = 0; ij < sizeof(jdouble); ij++) { + u.ival = ddata; + for (ij = 0; (size_t) ij < sizeof(jdouble); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_doubleToByte__D */ - /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_longToByte__J - (JNIEnv *env, jclass clss, jlong idata) /* IN: array of long */ + (JNIEnv *env, jclass clss, jlong ldata) /* IN: long */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { jlong ival; char bytes[sizeof(jlong)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jlong)); - if (rarray == NULL) { - h5outOfMemory( env, "longToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "longToByte: getLong failed?"); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jlong)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "longToByte: byte array not pinned"); bap = barray; - u.ival = idata; - for (ij = 0; ij < sizeof(jlong); ij++) { + u.ival = ldata; + for (ij = 0; (size_t) ij < sizeof(jlong); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_longToByte__J */ @@ -1172,38 +1053,35 @@ Java_hdf_hdf5lib_HDFNativeData_longToByte__J /* returns byte [] */ JNIEXPORT jbyteArray JNICALL Java_hdf_hdf5lib_HDFNativeData_byteToByte__B - (JNIEnv *env, jclass clss, jbyte idata) /* IN: array of long */ + (JNIEnv *env, jclass clss, jbyte bdata) /* IN: byte */ { - jbyteArray rarray; - jbyte *barray; - jbyte *bap; - jboolean bb; - int ij; + jbyteArray rarray; + jboolean bb; + jbyte *barray = NULL; + jbyte *bap = NULL; + int ij; union things { jbyte ival; char bytes[sizeof(jbyte)]; } u; - rarray = ENVPTR->NewByteArray(ENVPAR sizeof(jbyte)); - if (rarray == NULL) { - h5outOfMemory( env, "byteToByte" ); - return NULL; - } /* end if */ + UNUSED(clss); - barray = ENVPTR->GetByteArrayElements(ENVPAR rarray,&bb); - if (barray == NULL) { - h5JNIFatalError( env, "byteToByte: getByte failed?"); - return NULL; - } /* end if */ + if (NULL == (rarray = ENVPTR->NewByteArray(ENVONLY, sizeof(jbyte)))) + CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); + + PIN_BYTE_ARRAY(ENVONLY, rarray, barray, &bb, "byteToByte: byte array not pinned"); bap = barray; - u.ival = idata; - for (ij = 0; ij < sizeof(jbyte); ij++) { + u.ival = bdata; + for (ij = 0; (size_t) ij < sizeof(jbyte); ij++) { *bap = u.bytes[ij]; bap++; } /* end for */ - ENVPTR->ReleaseByteArrayElements(ENVPAR rarray,(jbyte *)barray, 0); +done: + if (barray) + UNPIN_BYTE_ARRAY(ENVONLY, rarray, barray, 0); return rarray; } /* end Java_hdf_hdf5lib_HDFNativeData_byteToByte__B */ diff --git a/java/test/TestH5.java b/java/test/TestH5.java index 54603ca..c59101b 100644 --- a/java/test/TestH5.java +++ b/java/test/TestH5.java @@ -177,6 +177,23 @@ public class TestH5 { for (int i = 0; i < 2; i++) assertFalse(libversion[i] == 0); } + + /** + * Test method for {@link hdf.hdf5lib.H5#H5get_libversion(int[])} + * to ensure a null libversion parameter causes the function to + * fail. + */ + @Test + public void testH5get_libversion_null_param() { + try { + H5.H5get_libversion(null); + } + catch (Throwable err) { + return; + } + + fail("H5.H5get_libversion: succeeded with a null libversion parameter!"); + } /** * Test method for diff --git a/java/test/testfiles/JUnit-TestH5.txt b/java/test/testfiles/JUnit-TestH5.txt index 37c5b65..b282a91 100644 --- a/java/test/testfiles/JUnit-TestH5.txt +++ b/java/test/testfiles/JUnit-TestH5.txt @@ -1,4 +1,5 @@ JUnit version 4.11 +.testH5get_libversion_null_param .testJ2C .testIsSerializable .testH5garbage_collect @@ -11,5 +12,5 @@ JUnit version 4.11 Time: XXXX -OK (9 tests) +OK (10 tests) diff --git a/src/H5Torder.c b/src/H5Torder.c index d687d03..62662d6 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -100,11 +100,11 @@ H5Tget_order(hid_t type_id) /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, H5T_ORDER_ERROR, "not a 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))) - HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "cant't get order for specified datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, H5T_ORDER_ERROR, "can't get order for specified datatype") done: FUNC_LEAVE_API(ret_value) -- cgit v0.12 From d98faf57030a2843511047fa701acf379569a2d6 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 11:09:43 -0600 Subject: Rename parallel tests to start with PAR_ --- examples/CMakeTests.cmake | 4 ++-- fortran/examples/CMakeTests.cmake | 4 ++-- fortran/testpar/CMakeTests.cmake | 2 +- testpar/CMakeTests.cmake | 10 +++++----- testpar/CMakeVFDTests.cmake | 2 +- tools/test/h5diff/CMakeTests.cmake | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index dd1e03b..9fc12eb 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -181,9 +181,9 @@ ### Windows pops up a modal permission dialog on this test if (H5_HAVE_PARALLEL AND NOT WIN32) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES_PAR-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) else () - add_test (NAME EXAMPLES_PAR-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME PAR_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 323cf91..3dd5d6a 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -151,8 +151,8 @@ foreach (example ${F2003_examples}) endforeach () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - add_test (NAME f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (BUILD_SHARED_LIBS) - add_test (NAME f90_ex-shared_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_f90_ex-shared_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () diff --git a/fortran/testpar/CMakeTests.cmake b/fortran/testpar/CMakeTests.cmake index d00a6fc..12fd13b 100644 --- a/fortran/testpar/CMakeTests.cmake +++ b/fortran/testpar/CMakeTests.cmake @@ -15,4 +15,4 @@ ### T E S T I N G ### ############################################################################## ############################################################################## -add_test (NAME FORT_parallel_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) +add_test (NAME PAR_FORT_parallel_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index a0d7f59..a7c606d 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -16,16 +16,16 @@ ############################################################################## ############################################################################## -add_test (NAME TEST_PAR_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) +add_test (NAME PAR_TEST_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) foreach (testp ${H5P_TESTS}) - add_test (NAME TEST_PAR_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME PAR_TEST_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endforeach () # The t_pflush1 test is hard-coded to fail. -set_tests_properties (TEST_PAR_t_pflush1 PROPERTIES WILL_FAIL "true") -#set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") -set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) +set_tests_properties (PAR_TEST_t_pflush1 PROPERTIES WILL_FAIL "true") +#set_property (TEST PAR_TEST_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") +set_tests_properties (PAR_TEST_t_pflush2 PROPERTIES DEPENDS PAR_TEST_t_pflush1) ############################################################################## ############################################################################## diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index b6b065f..ed6c898 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -37,7 +37,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) foreach (test ${H5P_VFD_TESTS}) add_test ( - NAME TEST_PAR_VFD-${vfdname}-${test} + NAME PAR_TEST_VFD-${vfdname}-${test} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index 24646b0..fc0018b 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -394,7 +394,7 @@ macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PH5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${ARGN}) + add_test (NAME PAR_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${ARGN}) set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") if (NOT "${resultcode}" STREQUAL "0") set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") -- cgit v0.12 From edcbc9966f5c742970ad32eb50a7925fcf7ab677 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 12:01:25 -0600 Subject: Refactor parallel test names --- bin/batch/cori_ctestP.sl.in.cmake | 2 +- bin/batch/cori_ctestS.sl.in.cmake | 2 +- bin/batch/cori_knl_ctestP.sl.in.cmake | 2 +- bin/batch/cori_knl_ctestS.sl.in.cmake | 2 +- bin/batch/ctestP.sl.in.cmake | 2 +- bin/batch/ctestS.sl.in.cmake | 2 +- bin/batch/knl_ctestP.sl.in.cmake | 2 +- bin/batch/knl_ctestS.sl.in.cmake | 2 +- bin/batch/ray_ctestP.lsf.in.cmake | 2 +- bin/batch/ray_ctestS.lsf.in.cmake | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/batch/cori_ctestP.sl.in.cmake b/bin/batch/cori_ctestP.sl.in.cmake index 6aa4916..af43410 100644 --- a/bin/batch/cori_ctestP.sl.in.cmake +++ b/bin/batch/cori_ctestP.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R TEST_PAR|PH5DIFF|PERFORM|ph5example -E t_cache_image -C Release -T test" +CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/cori_ctestS.sl.in.cmake b/bin/batch/cori_ctestS.sl.in.cmake index cf68826..be9267a 100644 --- a/bin/batch/cori_ctestS.sl.in.cmake +++ b/bin/batch/cori_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E TEST_PAR|PH5DIFF|PERFORM|ph5example -C Release -j 32 -T test" +CMD="ctest . -E PAR_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/cori_knl_ctestP.sl.in.cmake b/bin/batch/cori_knl_ctestP.sl.in.cmake index 90dd52a..38fa81d 100644 --- a/bin/batch/cori_knl_ctestP.sl.in.cmake +++ b/bin/batch/cori_knl_ctestP.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R TEST_PAR|PH5DIFF|PERFORM|ph5example -E t_cache_image -C Release -T test" +CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/cori_knl_ctestS.sl.in.cmake b/bin/batch/cori_knl_ctestS.sl.in.cmake index 7db4483..5474672 100644 --- a/bin/batch/cori_knl_ctestS.sl.in.cmake +++ b/bin/batch/cori_knl_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E TEST_PAR|PH5DIFF|PERFORM|ph5example -C Release -j 32 -T test" +CMD="ctest . -E PAR_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/ctestP.sl.in.cmake b/bin/batch/ctestP.sl.in.cmake index 9fed14d..eadf336 100644 --- a/bin/batch/ctestP.sl.in.cmake +++ b/bin/batch/ctestP.sl.in.cmake @@ -8,7 +8,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R TEST_PAR|PH5DIFF|PERFORM|ph5example -E t_cache_image -C Release -T test" +CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/ctestS.sl.in.cmake b/bin/batch/ctestS.sl.in.cmake index 98c1bcd..6f97d2b 100644 --- a/bin/batch/ctestS.sl.in.cmake +++ b/bin/batch/ctestS.sl.in.cmake @@ -8,7 +8,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E TEST_PAR|PH5DIFF|PERFORM|ph5example -C Release -j 32 -T test" +CMD="ctest . -E PAR_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/knl_ctestP.sl.in.cmake b/bin/batch/knl_ctestP.sl.in.cmake index 5c7c83f..3e5cbe5 100644 --- a/bin/batch/knl_ctestP.sl.in.cmake +++ b/bin/batch/knl_ctestP.sl.in.cmake @@ -10,7 +10,7 @@ cd @HDF5_BINARY_DIR@ #run parallel tests except t_cache_image test -CMD="ctest . -R TEST_PAR|PH5DIFF|PERFORM|ph5example -E t_cache_image -C Release -T test" +CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/knl_ctestS.sl.in.cmake b/bin/batch/knl_ctestS.sl.in.cmake index 0dae31f..d099666 100644 --- a/bin/batch/knl_ctestS.sl.in.cmake +++ b/bin/batch/knl_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E TEST_PAR|PH5DIFF|PERFORM|ph5example -C Release -j 32 -T test" +CMD="ctest . -E PAR_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/ray_ctestP.lsf.in.cmake b/bin/batch/ray_ctestP.lsf.in.cmake index 6b5316a..8ffaf8c 100644 --- a/bin/batch/ray_ctestP.lsf.in.cmake +++ b/bin/batch/ray_ctestP.lsf.in.cmake @@ -15,6 +15,6 @@ cd @HDF5_BINARY_DIR@ echo "Run parallel test command. Test output will be in build/ctestP.out" -ctest . -R 'TEST_PAR|PH5DIFF|PERFORM|ph5example' -E t_cache_image -C Release -T test >& ctestP.out +ctest . -R 'PAR_' -E t_cache_image -C Release -T test >& ctestP.out echo "Done running ctest parallel command." diff --git a/bin/batch/ray_ctestS.lsf.in.cmake b/bin/batch/ray_ctestS.lsf.in.cmake index d23a513..5bd5c83 100644 --- a/bin/batch/ray_ctestS.lsf.in.cmake +++ b/bin/batch/ray_ctestS.lsf.in.cmake @@ -11,7 +11,7 @@ cd @HDF5_BINARY_DIR@ echo "Run command. Test output will be in build/ctestS.out" -ctest . -E 'TEST_PAR|PH5DIFF|PERFORM|ph5example' -C Release -j 32 -T test >& ctestS.out +ctest . -E 'PAR_' -C Release -j 32 -T test >& ctestS.out ##$CMD >& ctestS.out echo "Done running command." -- cgit v0.12 From 6f71b2cdcf3326b1d7bc67cf664b56d2f4056bfd Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 11 Feb 2019 12:42:19 -0600 Subject: Refactor mpi test names --- bin/batch/cori_ctestP.sl.in.cmake | 2 +- bin/batch/cori_ctestS.sl.in.cmake | 2 +- bin/batch/cori_knl_ctestP.sl.in.cmake | 2 +- bin/batch/cori_knl_ctestS.sl.in.cmake | 2 +- bin/batch/ctestP.sl.in.cmake | 2 +- bin/batch/ctestS.sl.in.cmake | 2 +- bin/batch/knl_ctestP.sl.in.cmake | 2 +- bin/batch/knl_ctestS.sl.in.cmake | 2 +- bin/batch/ray_ctestP.lsf.in.cmake | 2 +- bin/batch/ray_ctestS.lsf.in.cmake | 2 +- examples/CMakeTests.cmake | 18 +++++++++--------- fortran/examples/CMakeTests.cmake | 4 ++-- fortran/testpar/CMakeTests.cmake | 2 +- testpar/CMakeTests.cmake | 10 +++++----- testpar/CMakeVFDTests.cmake | 2 +- tools/test/h5diff/CMakeTests.cmake | 16 ++++++++-------- tools/test/perform/CMakeTests.cmake | 4 ++-- 17 files changed, 38 insertions(+), 38 deletions(-) diff --git a/bin/batch/cori_ctestP.sl.in.cmake b/bin/batch/cori_ctestP.sl.in.cmake index af43410..287fe3c 100644 --- a/bin/batch/cori_ctestP.sl.in.cmake +++ b/bin/batch/cori_ctestP.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" +CMD="ctest . -R MPI_TEST_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/cori_ctestS.sl.in.cmake b/bin/batch/cori_ctestS.sl.in.cmake index be9267a..50bef6b 100644 --- a/bin/batch/cori_ctestS.sl.in.cmake +++ b/bin/batch/cori_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E PAR_ -C Release -j 32 -T test" +CMD="ctest . -E MPI_TEST_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/cori_knl_ctestP.sl.in.cmake b/bin/batch/cori_knl_ctestP.sl.in.cmake index 38fa81d..82378ec 100644 --- a/bin/batch/cori_knl_ctestP.sl.in.cmake +++ b/bin/batch/cori_knl_ctestP.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" +CMD="ctest . -R MPI_TEST_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/cori_knl_ctestS.sl.in.cmake b/bin/batch/cori_knl_ctestS.sl.in.cmake index 5474672..bcb4881 100644 --- a/bin/batch/cori_knl_ctestS.sl.in.cmake +++ b/bin/batch/cori_knl_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E PAR_ -C Release -j 32 -T test" +CMD="ctest . -E MPI_TEST_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/ctestP.sl.in.cmake b/bin/batch/ctestP.sl.in.cmake index eadf336..8d216d6 100644 --- a/bin/batch/ctestP.sl.in.cmake +++ b/bin/batch/ctestP.sl.in.cmake @@ -8,7 +8,7 @@ #SBATCH --job-name=h5_ctestP cd @HDF5_BINARY_DIR@ -CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" +CMD="ctest . -R MPI_TEST_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/ctestS.sl.in.cmake b/bin/batch/ctestS.sl.in.cmake index 6f97d2b..4f96bb9 100644 --- a/bin/batch/ctestS.sl.in.cmake +++ b/bin/batch/ctestS.sl.in.cmake @@ -8,7 +8,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E PAR_ -C Release -j 32 -T test" +CMD="ctest . -E MPI_TEST_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/knl_ctestP.sl.in.cmake b/bin/batch/knl_ctestP.sl.in.cmake index 3e5cbe5..79dfb89 100644 --- a/bin/batch/knl_ctestP.sl.in.cmake +++ b/bin/batch/knl_ctestP.sl.in.cmake @@ -10,7 +10,7 @@ cd @HDF5_BINARY_DIR@ #run parallel tests except t_cache_image test -CMD="ctest . -R PAR_ -E t_cache_image -C Release -T test" +CMD="ctest . -R MPI_TEST_ -E t_cache_image -C Release -T test" echo "Run $CMD. Test output will be in build/ctestP.out" $CMD >& ctestP.out diff --git a/bin/batch/knl_ctestS.sl.in.cmake b/bin/batch/knl_ctestS.sl.in.cmake index d099666..af6353b 100644 --- a/bin/batch/knl_ctestS.sl.in.cmake +++ b/bin/batch/knl_ctestS.sl.in.cmake @@ -9,7 +9,7 @@ #SBATCH --job-name=h5_ctestS cd @HDF5_BINARY_DIR@ -CMD="ctest . -E PAR_ -C Release -j 32 -T test" +CMD="ctest . -E MPI_TEST_ -C Release -j 32 -T test" echo "Run $CMD. Test output will be in build/ctestS.out" $CMD >& ctestS.out diff --git a/bin/batch/ray_ctestP.lsf.in.cmake b/bin/batch/ray_ctestP.lsf.in.cmake index 8ffaf8c..082276a 100644 --- a/bin/batch/ray_ctestP.lsf.in.cmake +++ b/bin/batch/ray_ctestP.lsf.in.cmake @@ -15,6 +15,6 @@ cd @HDF5_BINARY_DIR@ echo "Run parallel test command. Test output will be in build/ctestP.out" -ctest . -R 'PAR_' -E t_cache_image -C Release -T test >& ctestP.out +ctest . -R 'MPI_TEST_' -E t_cache_image -C Release -T test >& ctestP.out echo "Done running ctest parallel command." diff --git a/bin/batch/ray_ctestS.lsf.in.cmake b/bin/batch/ray_ctestS.lsf.in.cmake index 5bd5c83..da20438 100644 --- a/bin/batch/ray_ctestS.lsf.in.cmake +++ b/bin/batch/ray_ctestS.lsf.in.cmake @@ -11,7 +11,7 @@ cd @HDF5_BINARY_DIR@ echo "Run command. Test output will be in build/ctestS.out" -ctest . -E 'PAR_' -C Release -j 32 -T test >& ctestS.out +ctest . -E 'MPI_TEST_' -C Release -j 32 -T test >& ctestS.out ##$CMD >& ctestS.out echo "Done running command." diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index 9fc12eb..cb47c78 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -181,9 +181,9 @@ ### Windows pops up a modal permission dialog on this test if (H5_HAVE_PARALLEL AND NOT WIN32) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PAR_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) else () - add_test (NAME PAR_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME MPI_TEST_EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -195,14 +195,14 @@ ) endif () if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES_PAR-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (MPI_TEST_EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES_PAR-ph5example") + set (last_test "MPI_TEST_EXAMPLES-ph5example") if (BUILD_SHARED_LIBS) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_EXAMPLES-shared-ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) else () - add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME MPI_TEST_EXAMPLES-shared-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -213,10 +213,10 @@ -P "${HDF_RESOURCES_EXT_DIR}/grepTest.cmake" ) endif () - set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) + set_tests_properties (MPI_TEST_EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (MPI_TEST_EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES_PAR-shared-ph5example") + set (last_test "MPI_TEST_EXAMPLES-shared-ph5example") endif () endif () diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 3dd5d6a..face086 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -151,8 +151,8 @@ foreach (example ${F2003_examples}) endforeach () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - add_test (NAME PAR_f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_f90_ex_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (BUILD_SHARED_LIBS) - add_test (NAME PAR_f90_ex-shared_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_f90_ex-shared_ph5example COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () diff --git a/fortran/testpar/CMakeTests.cmake b/fortran/testpar/CMakeTests.cmake index 12fd13b..d0abe0e 100644 --- a/fortran/testpar/CMakeTests.cmake +++ b/fortran/testpar/CMakeTests.cmake @@ -15,4 +15,4 @@ ### T E S T I N G ### ############################################################################## ############################################################################## -add_test (NAME PAR_FORT_parallel_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) +add_test (NAME MPI_TEST_FORT_parallel_test COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index a7c606d..b71e7bc 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -16,16 +16,16 @@ ############################################################################## ############################################################################## -add_test (NAME PAR_TEST_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) +add_test (NAME MPI_TEST_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) foreach (testp ${H5P_TESTS}) - add_test (NAME PAR_TEST_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endforeach () # The t_pflush1 test is hard-coded to fail. -set_tests_properties (PAR_TEST_t_pflush1 PROPERTIES WILL_FAIL "true") -#set_property (TEST PAR_TEST_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") -set_tests_properties (PAR_TEST_t_pflush2 PROPERTIES DEPENDS PAR_TEST_t_pflush1) +set_tests_properties (MPI_TEST_t_pflush1 PROPERTIES WILL_FAIL "true") +#set_property (TEST MPI_TEST_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") +set_tests_properties (MPI_TEST_t_pflush2 PROPERTIES DEPENDS MPI_TEST_t_pflush1) ############################################################################## ############################################################################## diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index ed6c898..e2bf88a 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -37,7 +37,7 @@ if (NOT HDF5_ENABLE_USING_MEMCHECKER) foreach (test ${H5P_VFD_TESTS}) add_test ( - NAME PAR_TEST_VFD-${vfdname}-${test} + NAME MPI_TEST_VFD-${vfdname}-${test} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index fc0018b..1376e0d 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -394,28 +394,28 @@ macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME PAR_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${ARGN}) - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") + add_test (NAME MPI_TEST_H5DIFF-${resultfile} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${ARGN}) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/PAR/testfiles") if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES WILL_FAIL "true") endif () if (NOT "${last_test}" STREQUAL "") - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS ${last_test}) endif () else () # Remove any output file left over from previous test run add_test ( - NAME PH5DIFF-${resultfile}-clear-objects + NAME MPI_TEST_H5DIFF-${resultfile}-clear-objects COMMAND ${CMAKE_COMMAND} -E remove PAR/testfiles/${resultfile}.out PAR/testfiles/${resultfile}.out.err ) if (NOT "${last_test}" STREQUAL "") - set_tests_properties (PH5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) endif () add_test ( - NAME PH5DIFF-${resultfile} + NAME MPI_TEST_H5DIFF-${resultfile} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=${MPIEXEC_EXECUTABLE};${MPIEXEC_NUMPROC_FLAG};${MPIEXEC_MAX_NUMPROCS};${MPIEXEC_PREFLAGS};$;${MPIEXEC_POSTFLAGS}" -D "TEST_ARGS:STRING=${ARGN}" @@ -429,7 +429,7 @@ -D "TEST_SORT_COMPARE=TRUE" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) - set_tests_properties (PH5DIFF-${resultfile} PROPERTIES DEPENDS PH5DIFF-${resultfile}-clear-objects) + set_tests_properties (MPI_TEST_H5DIFF-${resultfile} PROPERTIES DEPENDS MPI_TEST_H5DIFF-${resultfile}-clear-objects) set (last_test "PH5DIFF-${resultfile}") endif () endmacro () diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 02dc15d..36172d1 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -170,9 +170,9 @@ endif () set_tests_properties (PERFORM_zip_perf PROPERTIES DEPENDS "PERFORM_zip_perf_help;PERFORM_h5perform-clearall-objects") if (H5_HAVE_PARALLEL) - add_test (NAME PAR_PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PAR_PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + add_test (NAME MPI_TEST_PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) endif () endif () -- cgit v0.12 From 65a820ae8981a84fe7fbac87c48482e9f82b35f4 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Fri, 25 Jan 2019 15:32:51 -0600 Subject: Fix some collective metadata read issues --- release_docs/RELEASE.txt | 16 +++ src/H5C.c | 55 ++------ src/H5CX.c | 4 +- src/H5Cimage.c | 4 +- src/H5Dchunk.c | 22 +--- src/H5Dmpio.c | 6 +- src/H5Z.c | 2 +- testpar/t_cache.c | 16 +-- testpar/t_coll_md_read.c | 336 +++++++++++++++++++++++++++++++++++++++++++++-- testpar/testphdf5.c | 5 +- testpar/testphdf5.h | 2 + 11 files changed, 381 insertions(+), 87 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 2dfcfc1..9e63045 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -264,6 +264,22 @@ Bug Fixes since HDF5-1.10.3 release Library ------- + - Fix hangs with collective metadata reads during chunked dataset I/O + + In the parallel library, it was discovered that when a particular + sequence of operations following a pattern of: + + "write to chunked dataset" -> "flush file" -> "read from dataset" + + occurred with collective metadata reads enabled, hangs could be + observed due to certain MPI ranks not participating in the collective + metadata reads. + + To fix the issue, collective metadata reads are now disabled during + chunked dataset raw data I/O. + + (JTH - 2019/02/11, HDFFV-10563, HDFFV-10688) + - Deleting attributes in dense storage The library aborts with "infinite loop closing library" after diff --git a/src/H5C.c b/src/H5C.c index b5dc6a5..70eb7ba 100644 --- a/src/H5C.c +++ b/src/H5C.c @@ -1482,31 +1482,17 @@ H5C_insert_entry(H5F_t * f, H5C__UPDATE_STATS_FOR_INSERTION(cache_ptr, entry_ptr) #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - coll_access = (H5P_USER_TRUE == f->coll_md_read ? TRUE : FALSE); - - /* If not explicitly disabled, get the cmdr setting from the API context */ - if(!coll_access && H5P_FORCE_FALSE != f->coll_md_read) - coll_access = H5CX_get_coll_metadata_read(); - } /* end if */ + 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) { 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(H5P_USER_TRUE == f->coll_md_read) { - if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) { - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") - } /* end if */ - } /* end if */ - else { - if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) { - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't clear collective metadata entries") - } /* end if */ - } /* end else */ + 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 @@ -2242,13 +2228,8 @@ H5C_protect(H5F_t * f, ring = H5CX_get_ring(); #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - coll_access = (H5P_USER_TRUE == f->coll_md_read ? TRUE : FALSE); - - /* If not explicitly disabled, get the cmdr setting from the API context */ - if(!coll_access && H5P_FORCE_FALSE != f->coll_md_read) - coll_access = H5CX_get_coll_metadata_read(); - } /* end if */ + 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 */ @@ -2285,7 +2266,7 @@ H5C_protect(H5F_t * f, the entry in their cache still have to participate in the bcast. */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI) && coll_access) { + if(coll_access) { if(!(entry_ptr->is_dirty) && !(entry_ptr->coll_access)) { MPI_Comm comm; /* File MPI Communicator */ int mpi_code; /* MPI error code */ @@ -2600,21 +2581,11 @@ H5C_protect(H5F_t * f, } /* end if */ #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { - /* Make sure the size of the collective entries in the cache remain in check */ - if(coll_access) { - if(H5P_USER_TRUE == f->coll_md_read) { - if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") - } /* end if */ - else { - if(cache_ptr->max_cache_size * 40 < cache_ptr->coll_list_size * 100) - if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") - } /* end else */ - } /* end if */ - } /* end if */ + /* Make sure the size of the collective entries in the cache remain in check */ + if(coll_access) + if(cache_ptr->max_cache_size * 80 < cache_ptr->coll_list_size * 100) + if(H5C_clear_coll_entries(cache_ptr, TRUE) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL, "can't clear collective metadata entries") #endif /* H5_HAVE_PARALLEL */ done: diff --git a/src/H5CX.c b/src/H5CX.c index 0d20132..f945df0 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -815,8 +815,8 @@ H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, #ifdef H5_HAVE_PARALLEL /* If this routine is not guaranteed to be collective (i.e. it doesn't - * modify the structural metadata in a file), check if we should use - * a collective metadata read. + * 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 */ diff --git a/src/H5Cimage.c b/src/H5Cimage.c index bdab1a3..4684630 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -1065,9 +1065,9 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) H5C__UPDATE_STATS_FOR_CACHE_IMAGE_READ(cache_ptr) #ifdef H5_HAVE_PARALLEL - if ( aux_ptr ) { + if ( aux_ptr ) { - /* Broadcast cache image */ + /* Broadcast cache image */ if ( MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, MPI_BYTE, diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index e165569..af8ff91 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -2914,9 +2914,6 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, /* 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 */ -#ifdef H5_HAVE_PARALLEL - H5P_coll_md_read_flag_t temp_cmr; /* Temp value to hold the coll metadata read setting */ -#endif /* H5_HAVE_PARALLEL */ /* Compose chunked index info struct */ idx_info.f = dset->oloc.file; @@ -2925,25 +2922,18 @@ H5D__chunk_lookup(const H5D_t *dset, const hsize_t *scaled, idx_info.storage = &dset->shared->layout.storage.u.chunk; #ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) { - /* disable collective metadata read for chunk indexes - as it is highly unlikely that users would read the - same chunks from all processes. MSC - might turn on - for root node? */ - temp_cmr = H5F_COLL_MD_READ(idx_info.f); - H5F_set_coll_md_read(idx_info.f, H5P_FORCE_FALSE); - } /* end if */ + /* Disable collective metadata read for chunk indexes as it is + * highly unlikely that users would read the same chunks from all + * processes. + */ + if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) + H5CX_set_coll_metadata_read(FALSE); #endif /* H5_HAVE_PARALLEL */ /* Go get the chunk information */ if((dset->shared->layout.storage.u.chunk.ops->get_addr)(&idx_info, udata) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't query chunk address") -#ifdef H5_HAVE_PARALLEL - if(H5F_HAS_FEATURE(idx_info.f, H5FD_FEAT_HAS_MPI)) - H5F_set_coll_md_read(idx_info.f, temp_cmr); -#endif /* H5_HAVE_PARALLEL */ - /* * Cache the information retrieved. * diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index f5da33d..0423006 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -800,6 +800,10 @@ H5D__chunk_collective_io(H5D_io_info_t *io_info, const H5D_type_info_t *type_inf HDassert(type_info); HDassert(fm); + /* Disable collective metadata reads for chunked dataset I/O operations + * in order to prevent potential hangs */ + H5CX_set_coll_metadata_read(FALSE); + /* Check the optional property list for the collective chunk IO optimization option */ if(H5CX_get_mpio_chunk_opt_mode(&chunk_opt_mode) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get chunk optimization option") @@ -2313,7 +2317,7 @@ if(H5DEBUG(D)) /* 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))) - HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) + HMPI_GOTO_ERROR(FAIL, "MPI_BCast failed", mpi_code) } /* end if */ /* Start at first node in chunk skip list */ diff --git a/src/H5Z.c b/src/H5Z.c index f41588f..0e2a7ba 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -611,7 +611,7 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) /* 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 + * different files). -QAK, 2018/02/14) */ if(H5_coll_api_sanity_check_g && !object->sanity_checked) { MPI_Comm mpi_comm; /* File's communicator */ diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 7488728..41c95e2 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -7225,7 +7225,7 @@ smoke_check_6(int metadata_write_strategy) /* some error occured in the server -- report failure */ nerrors++; if ( verbose ) { - HDfprintf(stdout, "%d:%s: server_main() failed.\n", + HDfprintf(stdout, "%d:%s: server_main() failed.\n", world_mpi_rank, FUNC); } } @@ -7241,7 +7241,7 @@ smoke_check_6(int metadata_write_strategy) fid = -1; cache_ptr = NULL; if ( verbose ) { - HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", + HDfprintf(stdout, "%d:%s: setup_cache_for_test() failed.\n", world_mpi_rank, FUNC); } } @@ -7250,7 +7250,7 @@ smoke_check_6(int metadata_write_strategy) virt_num_data_entries = NUM_DATA_ENTRIES; /* insert the first half collectively */ - file_ptr->coll_md_read = H5P_USER_TRUE; + H5CX_set_coll_metadata_read(TRUE); for ( i = 0; i < virt_num_data_entries/2; i++ ) { struct datum * entry_ptr; @@ -7271,7 +7271,7 @@ smoke_check_6(int metadata_write_strategy) } /* insert the other half independently */ - file_ptr->coll_md_read = H5P_USER_FALSE; + H5CX_set_coll_metadata_read(FALSE); for ( i = virt_num_data_entries/2; i < virt_num_data_entries; i++ ) { struct datum * entry_ptr; @@ -7291,7 +7291,7 @@ smoke_check_6(int metadata_write_strategy) HDassert(cache_ptr->max_cache_size*0.8 > cache_ptr->coll_list_size); } - /* flush the file */ + /* flush the file */ if ( H5Fflush(fid, H5F_SCOPE_GLOBAL) < 0 ) { nerrors++; if ( verbose ) { @@ -7301,7 +7301,7 @@ smoke_check_6(int metadata_write_strategy) } /* Protect the first half of the entries collectively */ - file_ptr->coll_md_read = H5P_USER_TRUE; + H5CX_set_coll_metadata_read(TRUE); for ( i = 0; i < (virt_num_data_entries / 2); i++ ) { struct datum * entry_ptr; @@ -7322,13 +7322,13 @@ smoke_check_6(int metadata_write_strategy) } /* protect the other half independently */ - file_ptr->coll_md_read = H5P_USER_FALSE; + H5CX_set_coll_metadata_read(FALSE); for ( i = virt_num_data_entries/2; i < virt_num_data_entries; i++ ) { struct datum * entry_ptr; entry_ptr = &(data[i]); - lock_entry(file_ptr, i); + lock_entry(file_ptr, i); if(FALSE != entry_ptr->header.coll_access) { nerrors++; diff --git a/testpar/t_coll_md_read.c b/testpar/t_coll_md_read.c index f945d2b..912388c 100644 --- a/testpar/t_coll_md_read.c +++ b/testpar/t_coll_md_read.c @@ -32,6 +32,14 @@ #define PARTIAL_NO_SELECTION_Y_DIM_SCALE 5 #define PARTIAL_NO_SELECTION_X_DIM_SCALE 5 +#define MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS 2 + +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_NO_SEL_PROCESS (mpi_rank == mpi_size - 1) +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME "linked_chunk_io_sort_chunk_issue" +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE 20000 +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE 1 +#define LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS 1 + /* * A test for issue HDFFV-10501. A parallel hang was reported which occurred * in linked-chunk I/O when collective metadata reads are enabled and some ranks @@ -57,13 +65,13 @@ void test_partial_no_selection_coll_md_read(void) hsize_t stride[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t count[PARTIAL_NO_SELECTION_DATASET_NDIMS]; hsize_t block[PARTIAL_NO_SELECTION_DATASET_NDIMS]; - hid_t file_id = -1; - hid_t fapl_id = -1; - hid_t dset_id = -1; - hid_t dcpl_id = -1; - hid_t dxpl_id = -1; - hid_t fspace_id = -1; - hid_t mspace_id = -1; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; int mpi_rank, mpi_size; void *data = NULL; void *read_buf = NULL; @@ -86,7 +94,7 @@ void test_partial_no_selection_coll_md_read(void) file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); VRFY((file_id >= 0), "H5Fcreate succeeded"); - dataset_dims = malloc(PARTIAL_NO_SELECTION_DATASET_NDIMS * sizeof(*dataset_dims)); + dataset_dims = HDmalloc(PARTIAL_NO_SELECTION_DATASET_NDIMS * sizeof(*dataset_dims)); VRFY((dataset_dims != NULL), "malloc succeeded"); dataset_dims[0] = PARTIAL_NO_SELECTION_Y_DIM_SCALE * mpi_size; @@ -129,7 +137,7 @@ void test_partial_no_selection_coll_md_read(void) mspace_id = H5Screate_simple(1, sel_dims, NULL); VRFY((mspace_id >= 0), "H5Screate_simple succeeded"); - data = calloc(1, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); + data = HDcalloc(1, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); VRFY((data != NULL), "calloc succeeded"); dxpl_id = H5Pcreate(H5P_DATASET_XFER); @@ -151,7 +159,7 @@ void test_partial_no_selection_coll_md_read(void) */ VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); - read_buf = malloc(count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); + read_buf = HDmalloc(count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int)); VRFY((read_buf != NULL), "malloc succeeded"); /* @@ -171,21 +179,321 @@ void test_partial_no_selection_coll_md_read(void) * Check data integrity just to be sure. */ if (!PARTIAL_NO_SELECTION_NO_SEL_PROCESS) { - VRFY((!memcmp(data, read_buf, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int))), "memcmp succeeded"); + VRFY((!HDmemcmp(data, read_buf, count[1] * (PARTIAL_NO_SELECTION_Y_DIM_SCALE * PARTIAL_NO_SELECTION_X_DIM_SCALE) * sizeof(int))), "memcmp succeeded"); + } + + if (dataset_dims) { + HDfree(dataset_dims); + dataset_dims = NULL; } + if (data) { + HDfree(data); + data = NULL; + } + + if (read_buf) { + HDfree(read_buf); + read_buf = NULL; + } + + VRFY((H5Sclose(fspace_id) >= 0), "H5Sclose succeeded"); + VRFY((H5Sclose(mspace_id) >= 0), "H5Sclose succeeded"); + VRFY((H5Pclose(dcpl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Pclose(dxpl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Dclose(dset_id) >= 0), "H5Dclose succeeded"); + VRFY((H5Pclose(fapl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Fclose(file_id) >= 0), "H5Fclose succeeded"); +} + +/* + * A test for HDFFV-10562 which attempts to verify that using multi-chunk + * I/O with collective metadata reads enabled doesn't causes issues due to + * collective metadata reads being made only by process 0 in H5D__chunk_addrmap(). + * + * Failure in this test may either cause a hang, or, due to how the MPI calls + * pertaining to this issue might mistakenly match up, may cause an MPI error + * message similar to: + * + * #008: H5Dmpio.c line 2546 in H5D__obtain_mpio_mode(): MPI_BCast failed + * major: Internal error (too specific to document in detail) + * minor: Some MPI function failed + * #009: H5Dmpio.c line 2546 in H5D__obtain_mpio_mode(): Message truncated, error stack: + *PMPI_Bcast(1600)..................: MPI_Bcast(buf=0x1df98e0, count=18, MPI_BYTE, root=0, comm=0x84000006) failed + *MPIR_Bcast_impl(1452).............: + *MPIR_Bcast(1476)..................: + *MPIR_Bcast_intra(1249)............: + *MPIR_SMP_Bcast(1088)..............: + *MPIR_Bcast_binomial(239)..........: + *MPIDI_CH3U_Receive_data_found(131): Message from rank 0 and tag 2 truncated; 2616 bytes received but buffer size is 18 + * major: Internal error (too specific to document in detail) + * minor: MPI Error String + * + */ +void test_multi_chunk_io_addrmap_issue(void) +{ + const char *filename; + hsize_t start[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t stride[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t count[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t block[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS]; + hsize_t dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {10, 5}; + hsize_t chunk_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {5, 5}; + hsize_t max_dims[MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS] = {H5S_UNLIMITED, H5S_UNLIMITED}; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + void *read_buf = NULL; + int mpi_rank; + int data[5][5] = { {0, 1, 2, 3, 4}, + {0, 1, 2, 3, 4}, + {0, 1, 2, 3, 4}, + {0, 1, 2, 3, 4}, + {0, 1, 2, 3, 4} }; + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + + filename = GetTestParameters(); + + fapl_id = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); + VRFY((fapl_id >= 0), "create_faccess_plist succeeded"); + + /* + * Even though the testphdf5 framework currently sets collective metadata reads + * on the FAPL, we call it here just to be sure this is futureproof, since + * demonstrating this issue relies upon it. + */ + VRFY((H5Pset_all_coll_metadata_ops(fapl_id, true) >= 0), "Set collective metadata reads succeeded"); + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + VRFY((file_id >= 0), "H5Fcreate succeeded"); + + space_id = H5Screate_simple(MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS, dims, max_dims); + VRFY((space_id >= 0), "H5Screate_simple succeeded"); + + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + VRFY((dcpl_id >= 0), "H5Pcreate succeeded"); + + VRFY((H5Pset_chunk(dcpl_id, MULTI_CHUNK_IO_ADDRMAP_ISSUE_DIMS, chunk_dims) >= 0), "H5Pset_chunk succeeded"); + + dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); + + dxpl_id = H5Pcreate(H5P_DATASET_XFER); + VRFY((dxpl_id >= 0), "H5Pcreate succeeded"); + + VRFY((H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) >= 0), "H5Pset_dxpl_mpio succeeded"); + VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_MULTI_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); + + start[1] = 0; + stride[0] = stride[1] = 1; + count[0] = count[1] = 5; + block[0] = block[1] = 1; + + if (mpi_rank == 0) + start[0] = 0; + else + start[0] = 5; + + VRFY((H5Sselect_hyperslab(space_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + if (mpi_rank != 0) + VRFY((H5Sselect_none(space_id) >= 0), "H5Sselect_none succeeded"); + + VRFY((H5Dwrite(dset_id, H5T_NATIVE_INT, H5S_ALL, space_id, dxpl_id, data) >= 0), "H5Dwrite succeeded"); + + VRFY((H5Fflush(file_id, H5F_SCOPE_GLOBAL) >= 0), "H5Fflush succeeded"); + + read_buf = HDmalloc(50 * sizeof(int)); + VRFY((read_buf != NULL), "malloc succeeded"); + + VRFY((H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, dxpl_id, read_buf) >= 0), "H5Dread succeeded"); + + if (read_buf) { + HDfree(read_buf); + read_buf = NULL; + } + + VRFY((H5Sclose(space_id) >= 0), "H5Sclose succeeded"); + VRFY((H5Pclose(dcpl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Pclose(dxpl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Dclose(dset_id) >= 0), "H5Dclose succeeded"); + VRFY((H5Pclose(fapl_id) >= 0), "H5Pclose succeeded"); + VRFY((H5Fclose(file_id) >= 0), "H5Fclose succeeded"); +} + +/* + * A test for HDFFV-10562 which attempts to verify that using linked-chunk + * I/O with collective metadata reads enabled doesn't cause issues due to + * collective metadata reads being made only by process 0 in H5D__sort_chunk(). + * + * NOTE: Due to the way that the threshold value which pertains to this test + * is currently calculated within HDF5, there are several conditions that this + * test must maintain. Refer to the function H5D__sort_chunk in H5Dmpio.c for + * a better idea of why. + * + * Condition 1: We need to make sure that the test always selects every single + * chunk in the dataset. It is fine if the selection is split up among multiple + * ranks, but their combined selection must cover the whole dataset. + * + * Condition 2: The number of chunks in the dataset divided by the number of MPI + * ranks must exceed or equal 10000. In other words, each MPI rank must be + * responsible for 10000 or more unique chunks. + * + * Condition 3: This test will currently only be reliably reproducable for 2 or 3 + * MPI ranks. The threshold value calculated reduces to a constant 100 / mpi_size, + * and is compared against a default value of 30%. + * + * Failure in this test may either cause a hang, or, due to how the MPI calls + * pertaining to this issue might mistakenly match up, may cause an MPI error + * message similar to: + * + * #008: H5Dmpio.c line 2338 in H5D__sort_chunk(): MPI_BCast failed + * major: Internal error (too specific to document in detail) + * minor: Some MPI function failed + * #009: H5Dmpio.c line 2338 in H5D__sort_chunk(): Other MPI error, error stack: + *PMPI_Bcast(1600)........: MPI_Bcast(buf=0x7eae610, count=320000, MPI_BYTE, root=0, comm=0x84000006) failed + *MPIR_Bcast_impl(1452)...: + *MPIR_Bcast(1476)........: + *MPIR_Bcast_intra(1249)..: + *MPIR_SMP_Bcast(1088)....: + *MPIR_Bcast_binomial(250): message sizes do not match across processes in the collective routine: Received 2096 but expected 320000 + * major: Internal error (too specific to document in detail) + * minor: MPI Error String + */ +void test_link_chunk_io_sort_chunk_issue(void) +{ + const char *filename; + hsize_t *dataset_dims = NULL; + hsize_t max_dataset_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t sel_dims[1]; + hsize_t chunk_dims[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS] = { LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS }; + hsize_t start[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t stride[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t count[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hsize_t block[LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS]; + hid_t file_id = H5I_INVALID_HID; + hid_t fapl_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t dxpl_id = H5I_INVALID_HID; + hid_t fspace_id = H5I_INVALID_HID; + hid_t mspace_id = H5I_INVALID_HID; + int mpi_rank, mpi_size; + void *data = NULL; + void *read_buf = NULL; + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + MPI_Comm_size(MPI_COMM_WORLD, &mpi_size); + + filename = GetTestParameters(); + + fapl_id = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type); + VRFY((fapl_id >= 0), "create_faccess_plist succeeded"); + + /* + * Even though the testphdf5 framework currently sets collective metadata reads + * on the FAPL, we call it here just to be sure this is futureproof, since + * demonstrating this issue relies upon it. + */ + VRFY((H5Pset_all_coll_metadata_ops(fapl_id, true) >= 0), "Set collective metadata reads succeeded"); + + file_id = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id); + VRFY((file_id >= 0), "H5Fcreate succeeded"); + + dataset_dims = HDmalloc(LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS * sizeof(*dataset_dims)); + VRFY((dataset_dims != NULL), "malloc succeeded"); + + dataset_dims[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE * mpi_size * LINK_CHUNK_IO_SORT_CHUNK_ISSUE_Y_DIM_SCALE; + max_dataset_dims[0] = H5S_UNLIMITED; + + fspace_id = H5Screate_simple(LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS, dataset_dims, max_dataset_dims); + VRFY((fspace_id >= 0), "H5Screate_simple succeeded"); + + /* + * Set up chunking on the dataset in order to reproduce the problem. + */ + dcpl_id = H5Pcreate(H5P_DATASET_CREATE); + VRFY((dcpl_id >= 0), "H5Pcreate succeeded"); + + VRFY((H5Pset_chunk(dcpl_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DIMS, chunk_dims) >= 0), "H5Pset_chunk succeeded"); + + dset_id = H5Dcreate2(file_id, LINK_CHUNK_IO_SORT_CHUNK_ISSUE_DATASET_NAME, H5T_NATIVE_INT, fspace_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT); + VRFY((dset_id >= 0), "H5Dcreate2 succeeded"); + + /* + * Setup hyperslab selection to split the dataset among the ranks. + * + * The ranks will write rows across the dataset. + */ + stride[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE; + count[0] = (dataset_dims[0] / LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) / mpi_size; + start[0] = count[0] * mpi_rank; + block[0] = LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE; + + VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + + sel_dims[0] = count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE); + + mspace_id = H5Screate_simple(1, sel_dims, NULL); + VRFY((mspace_id >= 0), "H5Screate_simple succeeded"); + + data = HDcalloc(1, count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) * sizeof(int)); + VRFY((data != NULL), "calloc succeeded"); + + dxpl_id = H5Pcreate(H5P_DATASET_XFER); + VRFY((dxpl_id >= 0), "H5Pcreate succeeded"); + + /* + * Enable collective access for the data transfer. + */ + VRFY((H5Pset_dxpl_mpio(dxpl_id, H5FD_MPIO_COLLECTIVE) >= 0), "H5Pset_dxpl_mpio succeeded"); + + VRFY((H5Dwrite(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, data) >= 0), "H5Dwrite succeeded"); + + VRFY((H5Fflush(file_id, H5F_SCOPE_GLOBAL) >= 0), "H5Fflush succeeded"); + + /* + * Ensure that linked-chunk I/O is performed since this is + * the particular code path where the issue lies and we don't + * want the library doing multi-chunk I/O behind our backs. + */ + VRFY((H5Pset_dxpl_mpio_chunk_opt(dxpl_id, H5FD_MPIO_CHUNK_ONE_IO) >= 0), "H5Pset_dxpl_mpio_chunk_opt succeeded"); + + read_buf = HDmalloc(count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) * sizeof(int)); + VRFY((read_buf != NULL), "malloc succeeded"); + + VRFY((H5Sselect_hyperslab(fspace_id, H5S_SELECT_SET, start, stride, count, block) >= 0), "H5Sselect_hyperslab succeeded"); + + sel_dims[0] = count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE); + + VRFY((H5Sclose(mspace_id) >= 0), "H5Sclose succeeded"); + + mspace_id = H5Screate_simple(1, sel_dims, NULL); + VRFY((mspace_id >= 0), "H5Screate_simple succeeded"); + + read_buf = HDrealloc(read_buf, count[0] * (LINK_CHUNK_IO_SORT_CHUNK_ISSUE_CHUNK_SIZE) * sizeof(int)); + VRFY((read_buf != NULL), "realloc succeeded"); + + /* + * Finally have each rank read their section of data back from the dataset. + */ + VRFY((H5Dread(dset_id, H5T_NATIVE_INT, mspace_id, fspace_id, dxpl_id, read_buf) >= 0), "H5Dread succeeded"); + if (dataset_dims) { - free(dataset_dims); + HDfree(dataset_dims); dataset_dims = NULL; } if (data) { - free(data); + HDfree(data); data = NULL; } if (read_buf) { - free(read_buf); + HDfree(read_buf); read_buf = NULL; } diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index 69b66ae..999e17a 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -549,7 +549,10 @@ int main(int argc, char **argv) AddTest("noselcollmdread", test_partial_no_selection_coll_md_read, NULL, "Collective Metadata read with some ranks having no selection", PARATESTFILE); - + AddTest("MC coll MD read", test_multi_chunk_io_addrmap_issue, NULL, + "Collective MD read with multi chunk I/O (H5D__chunk_addrmap)", PARATESTFILE); + AddTest("LC coll MD read", test_link_chunk_io_sort_chunk_issue, NULL, + "Collective MD read with link chunk I/O (H5D__sort_chunk)", PARATESTFILE); /* Display testing information */ TestInfo(argv[0]); diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 176574e..4409221 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -295,6 +295,8 @@ void compress_readAll(void); #endif /* H5_HAVE_FILTER_DEFLATE */ void test_dense_attr(void); void test_partial_no_selection_coll_md_read(void); +void test_multi_chunk_io_addrmap_issue(void); +void test_link_chunk_io_sort_chunk_issue(void); /* commonly used prototypes */ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type); -- cgit v0.12 From 8f447bd3564a88738b9a26b1b0ac3bba785efd39 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Mon, 11 Feb 2019 19:15:56 -0600 Subject: Add RELEASE.txt note for collective metadata read fixes --- release_docs/RELEASE.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index ef3bda0..316798d 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -264,6 +264,22 @@ Bug Fixes since HDF5-1.10.3 release Library ------- + - Fix hangs with collective metadata reads during chunked dataset I/O + + In the parallel library, it was discovered that when a particular + sequence of operations following a pattern of: + + "write to chunked dataset" -> "flush file" -> "read from dataset" + + occurred with collective metadata reads enabled, hangs could be + observed due to certain MPI ranks not participating in the collective + metadata reads. + + To fix the issue, collective metadata reads are now disabled during + chunked dataset raw data I/O. + + (JTH - 2019/02/11, HDFFV-10563, HDFFV-10688) + - Performance issue when closing an object The slow down is due to the search of the "tag_list" to find -- cgit v0.12 From 3acd486b83f319579b1c6884c90289b0eb1d44a6 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Tue, 12 Feb 2019 11:41:55 -0600 Subject: Fixes for JNI updates --- MANIFEST | 26 ++++++++++++++++++ java/src/jni/h5aImp.c | 63 +++++++++++++++++++++++++++++++++++++++++++ java/src/jni/h5dImp.c | 12 +++++++++ java/src/jni/h5eImp.c | 23 +++++++++++++--- java/src/jni/h5fImp.c | 18 +++++++++++++ java/src/jni/h5gImp.c | 12 +++++++++ java/src/jni/h5lImp.c | 55 +++++++++++++++++++++++++++++++++++++ java/src/jni/h5oImp.c | 31 +++++++++++++++++++++ java/src/jni/h5pDAPLImp.c | 3 +++ java/src/jni/h5pDCPLImp.c | 15 +++++++++-- java/src/jni/h5pDXPLImp.c | 3 +++ java/src/jni/h5pFAPLImp.c | 41 +++++++++++++++++++++------- java/src/jni/h5pImp.c | 39 +++++++++++++++++++++++++++ java/src/jni/h5pLAPLImp.c | 3 +++ java/src/jni/h5plImp.c | 12 +++++++++ java/src/jni/h5rImp.c | 2 ++ java/src/jni/h5sImp.c | 2 +- java/src/jni/h5tImp.c | 39 +++++++++++++++++++++------ java/src/jni/h5util.c | 18 ++++++++----- java/src/jni/h5vlImp.c | 9 +++++++ java/test/TestH5Edefault.java | 2 +- java/test/TestH5Oparams.java | 4 +-- java/test/TestH5Sbasic.java | 2 +- 23 files changed, 399 insertions(+), 35 deletions(-) diff --git a/MANIFEST b/MANIFEST index 2b48295..6c2018a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2900,6 +2900,32 @@ ./java/src/jni/h5oImp.h ./java/src/jni/h5pImp.c ./java/src/jni/h5pImp.h +./java/src/jni/h5pACPLImp.c +./java/src/jni/h5pACPLImp.h +./java/src/jni/h5pDAPLImp.c +./java/src/jni/h5pDAPLImp.h +./java/src/jni/h5pDCPLImp.c +./java/src/jni/h5pDCPLImp.h +./java/src/jni/h5pDXPLImp.c +./java/src/jni/h5pDXPLImp.h +./java/src/jni/h5pFAPLImp.c +./java/src/jni/h5pFAPLImp.h +./java/src/jni/h5pFCPLImp.c +./java/src/jni/h5pFCPLImp.h +./java/src/jni/h5pGAPLImp.c +./java/src/jni/h5pGAPLImp.h +./java/src/jni/h5pGCPLImp.c +./java/src/jni/h5pGCPLImp.h +./java/src/jni/h5pLAPLImp.c +./java/src/jni/h5pLAPLImp.h +./java/src/jni/h5pLCPLImp.c +./java/src/jni/h5pLCPLImp.h +./java/src/jni/h5pOCPLImp.c +./java/src/jni/h5pOCPLImp.h +./java/src/jni/h5pOCpyPLImp.c +./java/src/jni/h5pOCpyPLImp.h +./java/src/jni/h5pStrCPLImp.c +./java/src/jni/h5pStrCPLImp.h ./java/src/jni/h5plImp.c ./java/src/jni/h5plImp.h ./java/src/jni/h5rImp.c diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 666626f..e47515d 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -1533,6 +1533,9 @@ Java_hdf_hdf5lib_H5_H5Adelete UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Adelete: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Adelete: attribute name not pinned"); if ((status = H5Adelete((hid_t)loc_id, attrName)) < 0) @@ -1580,6 +1583,9 @@ Java_hdf_hdf5lib_H5__1H5Acreate2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Acreate2: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Acreate2: attribute name not pinned"); if ((status = H5Acreate2((hid_t)loc_id, attrName, (hid_t)type_id, @@ -1608,6 +1614,9 @@ Java_hdf_hdf5lib_H5__1H5Aopen UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, attrName, NULL, "H5Aopen: attribute name not pinned"); if ((retVal = H5Aopen((hid_t)obj_id, attrName, (hid_t)access_plist)) < 0) @@ -1634,6 +1643,9 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen_by_idx: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aopen_by_idx: object name not pinned"); if ((retVal = H5Aopen_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, @@ -1662,6 +1674,11 @@ Java_hdf_hdf5lib_H5__1H5Acreate_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Acreate_by_name: object name is NULL"); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Acreate_by_name: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Acreate_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Acreate_by_name: attribute name not pinned"); @@ -1693,6 +1710,11 @@ Java_hdf_hdf5lib_H5_H5Aexists_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aexists_by_name: object name is NULL"); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aexists_by_name: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aexists_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aexists_by_name: attribute name not pinned"); @@ -1725,6 +1747,11 @@ Java_hdf_hdf5lib_H5_H5Arename UNUSED(clss); + if (NULL == old_attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename: old attribute name is NULL"); + if (NULL == new_attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename: new attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, "H5Arename: old attribute name not pinned"); PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, "H5Arename: new attribute name not pinned"); @@ -1756,6 +1783,13 @@ Java_hdf_hdf5lib_H5_H5Arename_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename_by_name: object name is NULL"); + if (NULL == old_attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename_by_name: old attribute name is NULL"); + if (NULL == new_attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Arename_by_name: new attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Arename_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, old_attr_name, oldAttrName, NULL, "H5Arename_by_name: old attribute name not pinned"); PIN_JAVA_STRING(ENVONLY, new_attr_name, newAttrName, NULL, "H5Arename_by_name: new attribute name not pinned"); @@ -1790,6 +1824,9 @@ Java_hdf_hdf5lib_H5_H5Aget_1name_1by_1idx UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aget_name_by_idx: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_name_by_idx: object name not pinned"); /* Get the length of the attribute name */ @@ -1883,6 +1920,9 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1idx UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aget_info_by_idx: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_info_by_idx: object name not pinned"); if ((status = H5Aget_info_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, @@ -1921,6 +1961,11 @@ Java_hdf_hdf5lib_H5_H5Aget_1info_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aget_info_by_name: object name is NULL"); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aget_info_by_name: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aget_info_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aget_info_by_name: attribute name not pinned"); @@ -1958,6 +2003,11 @@ Java_hdf_hdf5lib_H5_H5Adelete_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Adelete_by_name: object name is NULL"); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Adelete_by_name: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Adelete_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Adelete_by_name: attribute name not pinned"); @@ -1987,6 +2037,9 @@ Java_hdf_hdf5lib_H5_H5Aexists UNUSED(clss); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aexists: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aexists: attribute name not pinned"); if ((bval = H5Aexists((hid_t)obj_id, attrName)) < 0) @@ -2015,6 +2068,9 @@ Java_hdf_hdf5lib_H5_H5Adelete_1by_1idx UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Adelete_by_idx: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Adelete_by_idx: object name not pinned"); if ((status = H5Adelete_by_idx((hid_t)loc_id, objName, (H5_index_t)idx_type, (H5_iter_order_t)order, (hsize_t)n, (hid_t)lapl_id)) < 0) @@ -2041,6 +2097,11 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1by_1name UNUSED(clss); + if (NULL == obj_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen_by_name: object name is NULL"); + if (NULL == attr_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aopen_by_name: attribute name is NULL"); + PIN_JAVA_STRING(ENVONLY, obj_name, objName, NULL, "H5Aopen_by_name: object name not pinned"); PIN_JAVA_STRING(ENVONLY, attr_name, attrName, NULL, "H5Aopen_by_name: attribute name not pinned"); @@ -2187,6 +2248,8 @@ Java_hdf_hdf5lib_H5_H5Aiterate_1by_1name H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate_by_name: op_data is NULL"); if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate_by_name: callback_op is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Aiterate_by_name: object name is NULL"); PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Aiterate_by_name: object name not pinned"); diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 0ed3b6e..92a3723 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -69,6 +69,9 @@ Java_hdf_hdf5lib_H5__1H5Dcreate UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dcreate: dataset name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate: dataset name not pinned"); if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, H5P_DEFAULT, (hid_t)create_plist_id, H5P_DEFAULT)) < 0) @@ -95,6 +98,9 @@ Java_hdf_hdf5lib_H5__1H5Dopen UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dopen: dataset name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dopen: dataset name not pinned"); if ((dset_id = H5Dopen2((hid_t)loc_id, dsetName, H5P_DEFAULT))) @@ -1677,6 +1683,9 @@ Java_hdf_hdf5lib_H5__1H5Dcreate2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dcreate2: dataset name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dcreate2: dataset name not pinned"); if ((dset_id = H5Dcreate2((hid_t)loc_id, dsetName, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) @@ -1703,6 +1712,9 @@ Java_hdf_hdf5lib_H5__1H5Dopen2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Dopen2: dataset name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, dsetName, NULL, "H5Dopen2: dataset name not pinned"); if ((dset_id = H5Dopen2((hid_t)loc_id, dsetName, (hid_t)access_plist)) < 0) diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c index 1c5a5a9..4ab00df 100644 --- a/java/src/jni/h5eImp.c +++ b/java/src/jni/h5eImp.c @@ -94,6 +94,13 @@ Java_hdf_hdf5lib_H5_H5Eregister_1class UNUSED(cls); + if (NULL == cls_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: class name is NULL"); + if (NULL == lib_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: lib name is NULL"); + if (NULL == version) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Eregister_class: version string is NULL"); + PIN_JAVA_STRING(ENVONLY, cls_name, the_cls_name, NULL, "H5Eregister_class: class name not pinned"); PIN_JAVA_STRING(ENVONLY, lib_name, the_lib_name, NULL, "H5Eregister_class: lib name not pinned"); PIN_JAVA_STRING(ENVONLY, version, the_version, NULL, "H5Eregister_class: version string not pinned"); @@ -171,6 +178,8 @@ Java_hdf_hdf5lib_H5_H5Ecreate_1msg if (err_id < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Ecreate_msg: invalid error class ID"); + if (NULL == err_msg) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ecreate_msg: error message string is NULL"); PIN_JAVA_STRING(ENVONLY, err_msg, the_err_msg, NULL, "H5Ecreate_msg: error message string not pinned"); @@ -376,13 +385,19 @@ Java_hdf_hdf5lib_H5_H5Epush2 UNUSED(cls); if (stk_id < 0) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid error stack ID"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid error stack ID"); if (class_id < 0) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid error class ID"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid error class ID"); if (major_id < 0) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid major error class ID"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid major error class ID"); if (minor_id < 0) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush: invalid minor error class ID"); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Epush2: invalid minor error class ID"); + if (NULL == filename) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: filename is NULL"); + if (NULL == funcname) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: function name is NULL"); + if (NULL == err_desc) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Epush2: error message is NULL"); PIN_JAVA_STRING(ENVONLY, filename, fName, NULL, "H5Epush2: filename not pinned"); PIN_JAVA_STRING(ENVONLY, funcname, fncName, NULL, "H5Epush2: function name not pinned"); diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 624c788..d145c6a 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -47,6 +47,9 @@ Java_hdf_hdf5lib_H5__1H5Fopen UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fopen: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fopen: file name not pinned"); if ((status = H5Fopen(fileName, (unsigned)flags, (hid_t)access_id)) < 0) @@ -73,6 +76,9 @@ Java_hdf_hdf5lib_H5__1H5Fcreate UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fcreate: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fcreate: file name not pinned"); if ((status = H5Fcreate(fileName, (unsigned)flags, create_id, access_id)) < 0) @@ -159,6 +165,9 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 H5_UNIMPLEMENTED(ENVONLY, "H5Fis_hdf5: not implemented"); #endif + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fis_hdf5: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fis_hdf5: file name not pinned"); if ((bval = H5Fis_hdf5(fileName)) < 0) @@ -187,6 +196,9 @@ Java_hdf_hdf5lib_H5_H5Fis_1accessible UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fis_accessible: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fis_accessible: file name not pinned"); if ((bval = H5Fis_accessible(fileName, (hid_t)file_id)) < 0) @@ -295,6 +307,9 @@ Java_hdf_hdf5lib_H5_H5Fmount UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Fmount: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Fmount: file name not pinned"); if ((status = H5Fmount((hid_t)loc_id, fileName, (hid_t)child_id, (hid_t)plist_id)) < 0) @@ -321,6 +336,9 @@ Java_hdf_hdf5lib_H5_H5Funmount UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Funmount: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Funmount: file name not pinned"); if ((status = H5Funmount((hid_t)loc_id, fileName)) < 0) diff --git a/java/src/jni/h5gImp.c b/java/src/jni/h5gImp.c index 8adabca..b579f31 100644 --- a/java/src/jni/h5gImp.c +++ b/java/src/jni/h5gImp.c @@ -126,6 +126,9 @@ Java_hdf_hdf5lib_H5__1H5Gcreate2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gcreate2: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gcreate2: group name not pinned"); if ((group_id = H5Gcreate2((hid_t)loc_id, grpName, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) @@ -172,6 +175,9 @@ Java_hdf_hdf5lib_H5__1H5Gopen2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gopen2: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gopen2: group name not pinned"); if ((group_id = H5Gopen2((hid_t)loc_id, grpName, (hid_t)access_plist_id)) < 0) @@ -245,6 +251,9 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1name UNUSED(cls); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_info_by_name: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gget_info_by_name: group name not pinned"); if ((ret_val = H5Gget_info_by_name((hid_t)loc_id, grpName, &group_info, (hid_t)lapl_id)) < 0) @@ -281,6 +290,9 @@ Java_hdf_hdf5lib_H5_H5Gget_1info_1by_1idx UNUSED(cls); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Gget_info_by_idx: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Gget_info_by_idx: group name not pinned"); if ((ret_val = H5Gget_info_by_idx((hid_t)loc_id, grpName, cindex_type, diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c index 5999270..af6c8ba 100644 --- a/java/src/jni/h5lImp.c +++ b/java/src/jni/h5lImp.c @@ -59,6 +59,11 @@ Java_hdf_hdf5lib_H5_H5Lcopy UNUSED(clss); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcopy: src name is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcopy: dest name is NULL"); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcopy: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcopy: dest name not pinned"); @@ -89,6 +94,13 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1external UNUSED(clss); + if (NULL == file_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_external: file name is NULL"); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_external: object name is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_external: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, file_name, lFileName, NULL, "H5Lcreate_external: file name not pinned"); PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_external: object name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_external: link name not pinned"); @@ -121,6 +133,11 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1hard UNUSED(clss); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_hard: object name is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_hard: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lcreate_hard: object name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lcreate_hard: link name not pinned"); @@ -150,6 +167,11 @@ Java_hdf_hdf5lib_H5_H5Lcreate_1soft UNUSED(clss); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_soft: link target is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lcreate_soft: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, cur_name, linkTarget, NULL, "H5Lcreate_soft: link target not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, linkName, NULL, "H5Lcreate_soft: link name not pinned"); @@ -177,6 +199,9 @@ Java_hdf_hdf5lib_H5_H5Ldelete UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ldelete: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Ldelete: link name not pinned"); if ((status = H5Ldelete((hid_t)loc_id, linkName, (hid_t)access_id)) < 0) @@ -203,6 +228,9 @@ Java_hdf_hdf5lib_H5_H5Ldelete_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ldelete_by_idx: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Ldelete_by_idx: group name not pinned"); if ((status = H5Ldelete_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, n, (hid_t)access_id)) < 0) @@ -227,6 +255,9 @@ Java_hdf_hdf5lib_H5_H5Lexists UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lexists: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lexists: link name not pinned"); if ((bval = H5Lexists((hid_t)loc_id, linkName, (hid_t)access_id)) < 0) @@ -258,6 +289,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1info UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_info: link name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_info: link name not pinned"); if ((status = H5Lget_info((hid_t)loc_id, linkName, &infobuf, (hid_t)access_id)) < 0) @@ -296,6 +330,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1info_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_info_by_idx: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_info_by_idx: group name not pinned"); if ((status = H5Lget_info_by_idx((hid_t)loc_id, groupName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (hid_t)access_id)) < 0) @@ -333,6 +370,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1name_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_name_by_idx: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Lget_name_by_idx: group name not pinned"); /* Get the length of the link name */ @@ -378,6 +418,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1value UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_value: link name is NULL"); + infobuf.type = H5L_TYPE_ERROR; PIN_JAVA_STRING(ENVONLY, name, linkName, NULL, "H5Lget_value: link name not pinned"); @@ -465,6 +508,9 @@ Java_hdf_hdf5lib_H5_H5Lget_1value_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lget_val_by_idx: group name is NULL"); + infobuf.type = H5L_TYPE_ERROR; PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lget_val_by_idx: group name not pinned"); @@ -551,6 +597,11 @@ Java_hdf_hdf5lib_H5_H5Lmove UNUSED(clss); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lmove: src name is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lmove: dest name is NULL"); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Lmove: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Lmove: dest name not pinned"); @@ -675,6 +726,8 @@ Java_hdf_hdf5lib_H5_H5Lvisit_1by_1name H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit_by_name: op_data is NULL"); if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit_by_name: callback_op is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Lvisit_by_name: group name is NULL"); PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Lvisit_by_name: group name not pinned"); @@ -743,6 +796,8 @@ Java_hdf_hdf5lib_H5_H5Literate_1by_1name H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate_by_name: op_data is NULL"); if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate_by_name: callback_op is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Literate_by_name: group name is NULL"); PIN_JAVA_STRING(ENVONLY, name, groupName, NULL, "H5Literate_by_name: group name not pinned"); diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c index 0b1a984..cc88b81 100644 --- a/java/src/jni/h5oImp.c +++ b/java/src/jni/h5oImp.c @@ -56,6 +56,9 @@ Java_hdf_hdf5lib_H5__1H5Oopen UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oopen: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oopen: object name not pinned"); if ((status = H5Oopen((hid_t)loc_id, objName, (hid_t)access_plist_id)) < 0) @@ -104,6 +107,11 @@ Java_hdf_hdf5lib_H5_H5Ocopy UNUSED(clss); + if (NULL == cur_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ocopy: src name is NULL"); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ocopy: dst name is NULL"); + PIN_JAVA_STRING(ENVONLY, cur_name, lCurName, NULL, "H5Ocopy: src name not pinned"); PIN_JAVA_STRING(ENVONLY, dst_name, lDstName, NULL, "H5Ocopy: dest name not pinned"); @@ -204,6 +212,9 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1name UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_name: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_info_by_name: object name not pinned"); if ((status = H5Oget_info_by_name2((hid_t)loc_id, objName, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) @@ -278,6 +289,9 @@ Java_hdf_hdf5lib_H5_H5Oget_1info_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_info_by_idx: group name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oget_info_by_idx: group name not pinned"); if ((status = H5Oget_info_by_idx2((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, &infobuf, (unsigned)fields, (hid_t)access_id)) < 0) @@ -346,6 +360,9 @@ Java_hdf_hdf5lib_H5_H5Olink UNUSED(clss); + if (NULL == dst_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Olink: link destination name is NULL"); + PIN_JAVA_STRING(ENVONLY, dst_name, linkDstName, NULL, "H5Olink: link destination name not pinned"); if ((status = H5Olink((hid_t)cur_loc_id, (hid_t)dst_loc_id, linkDstName, (hid_t)create_id, (hid_t)access_id)) < 0) @@ -525,6 +542,8 @@ Java_hdf_hdf5lib_H5_H5Ovisit_1by_1name H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit_by_name: op_data is NULL"); if (NULL == callback_op) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit_by_name: callback_op is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Ovisit_by_name: object name is NULL"); PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Ovisit_by_name: object name not pinned"); @@ -580,6 +599,9 @@ Java_hdf_hdf5lib_H5_H5Oset_1comment_1by_1name UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oset_comment_by_name: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oset_comment_by_name: object name not pinned"); if (NULL != comment) @@ -651,6 +673,9 @@ Java_hdf_hdf5lib_H5_H5Oget_1comment_1by_1name UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oget_comment_by_name: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oget_comment_by_name: object name not pinned"); /* Get the length of the comment */ @@ -692,6 +717,9 @@ Java_hdf_hdf5lib_H5_H5Oexists_1by_1name UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oexists_by_name: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, objName, NULL, "H5Oexists_by_name: object name not pinned"); if ((bval = H5Oexists_by_name((hid_t)loc_id, objName, (hid_t)access_id)) < 0) @@ -777,6 +805,9 @@ Java_hdf_hdf5lib_H5__1H5Oopen_1by_1idx UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Oopen_by_idx: object name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, grpName, NULL, "H5Oopen_by_idx: object name not pinned"); if ((retVal = H5Oopen_by_idx((hid_t)loc_id, grpName, (H5_index_t)index_field, (H5_iter_order_t)order, (hsize_t)link_n, (hid_t)lapl_id)) < 0) diff --git a/java/src/jni/h5pDAPLImp.c b/java/src/jni/h5pDAPLImp.c index 0afbbd6..fb39b84 100644 --- a/java/src/jni/h5pDAPLImp.c +++ b/java/src/jni/h5pDAPLImp.c @@ -119,6 +119,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1efile_1prefix UNUSED(clss); + if (NULL == prefix) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_efile_prefix: external file prefix is NULL"); + PIN_JAVA_STRING(ENVONLY, prefix, extFilePrefix, NULL, "H5Pset_efile_prefix: external file prefix not pinned"); if ((retVal = H5Pset_efile_prefix((hid_t)dapl_id, extFilePrefix)) < 0) diff --git a/java/src/jni/h5pDCPLImp.c b/java/src/jni/h5pDCPLImp.c index 0671843..7559c3b 100644 --- a/java/src/jni/h5pDCPLImp.c +++ b/java/src/jni/h5pDCPLImp.c @@ -1008,8 +1008,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1scaleoffset UNUSED(clss); - if (scale_factor <= 0) - H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_scaleoffset: scale factor must be > 0"); + if (scale_factor < 0) + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_scaleoffset: scale factor must be >= 0"); if (scale_type != H5Z_SO_FLOAT_DSCALE && scale_type != H5Z_SO_FLOAT_ESCALE && scale_type != H5Z_SO_INT) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Pset_scaleoffset: invalid scale type"); @@ -1074,6 +1074,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1external UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_external: file name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, fileName, NULL, "H5Pset_external: file name not pinned"); if ((status = H5Pset_external((hid_t)plist, fileName, (off_t)offset, (hsize_t)size)) < 0) @@ -1189,6 +1192,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1virtual UNUSED(clss); + if (NULL == src_file_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_virtual: src_file_name is NULL"); + if (NULL == src_dset_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_virtual: src_dset_name is NULL"); + PIN_JAVA_STRING(ENVONLY, src_file_name, fstr, NULL, "H5Pset_virtual: src_file_name not pinned"); PIN_JAVA_STRING(ENVONLY, src_dset_name, dstr, NULL, "H5Pset_virtual: src_dset_name not pinned"); @@ -1352,6 +1360,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1virtual_1prefix UNUSED(clss); + if (NULL == prefix) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_virtual_prefix: virtual prefix is NULL"); + PIN_JAVA_STRING(ENVONLY, prefix, virtPrefix, NULL, "H5Pset_virtual_prefix: virtual prefix not pinned"); if ((retVal = H5Pset_virtual_prefix((hid_t)dapl_id, virtPrefix)) < 0) diff --git a/java/src/jni/h5pDXPLImp.c b/java/src/jni/h5pDXPLImp.c index 2bdc36b..323fa8c 100644 --- a/java/src/jni/h5pDXPLImp.c +++ b/java/src/jni/h5pDXPLImp.c @@ -273,6 +273,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1data_1transform UNUSED(clss); + if (NULL == expression) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_data_transform: data transform expression is NULL"); + PIN_JAVA_STRING(ENVONLY, expression, express, NULL, "H5Pset_data_transform: data transform expression not pinned"); if ((retVal = H5Pset_data_transform((hid_t)plist_id, express)) < 0) diff --git a/java/src/jni/h5pFAPLImp.c b/java/src/jni/h5pFAPLImp.c index aec6581..acfc853 100644 --- a/java/src/jni/h5pFAPLImp.c +++ b/java/src/jni/h5pFAPLImp.c @@ -384,6 +384,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1log UNUSED(clss); + if (NULL == logfile) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_log: log file name is NULL"); + PIN_JAVA_STRING(ENVONLY, logfile, pLogfile, NULL, "H5Pset_fapl_log: log file name not pinned"); if ((retVal = H5Pset_fapl_log((hid_t)fapl_id, pLogfile, (unsigned long long)flags, (size_t)buf_size)) < 0) @@ -421,10 +424,12 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi jlongArray memb_fapl, jobjectArray memb_name, jlongArray memb_addr, jboolean relax) { const char * const *mName = NULL; + const char *utf8 = NULL; jboolean isCopy; jboolean bb; jobject o; jstring rstring; + jstring obj; jclass Sjc; size_t i; jlong *thefaplArray = NULL; @@ -445,11 +450,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi PIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, &isCopy, "H5Pset_fapl_multi: memb_addr not pinned"); if (memb_name) { - jstring obj; - for (i = 0; i < H5FD_MEM_NTYPES; i++) { - const char *utf8 = NULL; - size_t str_len; + size_t str_len; if (NULL == (obj = (jstring) ENVPTR->GetObjectArrayElement(ENVONLY, (jobjectArray) memb_name, (jsize) i))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -474,6 +476,7 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: memory allocation failed"); HDstrncpy(member_name[i], utf8, str_len + 1); + (member_name[i])[str_len] = '\0'; UNPIN_JAVA_STRING(ENVONLY, obj, utf8); utf8 = NULL; @@ -493,6 +496,8 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (!member_name[i]) continue; + if (NULL == (rstring = ENVPTR->NewStringUTF(ENVONLY, member_name[i]))) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); H5_JNI_FATAL_ERROR(ENVONLY, "H5Pset_fapl_multi: out of memory - unable to construct string from UTF characters"); @@ -522,7 +527,12 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1multi } done: - h5str_array_free(member_name, H5FD_MEM_NTYPES); + for (i = 0; i < H5FD_MEM_NTYPES; i++) { + if (member_name[i]) + HDfree(member_name[i]); + } + if (utf8) + UNPIN_JAVA_STRING(ENVONLY, obj, utf8); if (theaddrArray) UNPIN_LONG_ARRAY(ENVONLY, memb_addr, theaddrArray, (status < 0) ? JNI_ABORT : 0); if (thefaplArray) @@ -621,6 +631,11 @@ Java_hdf_hdf5lib_H5_H5Pset_1fapl_1split UNUSED(clss); + if (NULL == metaext) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_split: metaext is NULL"); + if (NULL == rawext) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_fapl_split: rawext is NULL"); + PIN_JAVA_STRING(ENVONLY, metaext, mstr, NULL, "H5Pset_fapl_split: metaext not pinned"); PIN_JAVA_STRING(ENVONLY, rawext, rstr, NULL, "H5Pset_fapl_split: rawext not pinned"); @@ -1125,12 +1140,17 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1config if (NULL == (j_str = (jstring)ENVPTR->GetObjectField(ENVONLY, cache_config, fid))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); - PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_mdc_config: cache_config not pinned"); + if (j_str) { + PIN_JAVA_STRING(ENVONLY, j_str, str, NULL, "H5Pset_mdc_config: cache_config not pinned"); - HDstrncpy(cacheinfo.trace_file_name, str, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + HDstrncpy(cacheinfo.trace_file_name, str, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); + cacheinfo.trace_file_name[H5AC__MAX_TRACE_FILE_NAME_LEN] = '\0'; - UNPIN_JAVA_STRING(ENVONLY, j_str, str); - str = NULL; + UNPIN_JAVA_STRING(ENVONLY, j_str, str); + str = NULL; + } + else + HDmemset(cacheinfo.trace_file_name, 0, H5AC__MAX_TRACE_FILE_NAME_LEN + 1); if (NULL == (fid = ENVPTR->GetFieldID(ENVONLY, cls, "evictions_enabled", "Z"))) CHECK_JNI_EXCEPTION(ENVONLY, JNI_FALSE); @@ -1383,6 +1403,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1mdc_1log_1options UNUSED(clss); + if (NULL == location) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_mdc_log_options: location string is NULL"); + PIN_JAVA_STRING(ENVONLY, location, locStr, NULL, "H5Pset_mdc_log_options: location string not pinned"); if ((retVal = H5Pset_mdc_log_options((hid_t)fapl_id, (hbool_t)is_enabled, locStr, (hbool_t)start_on_access)) < 0) diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index bed23c9..726e08c 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -174,6 +174,9 @@ Java_hdf_hdf5lib_H5__1H5Pcreate_1class close_callback = close_op; copy_callback = copy_op; + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "_H5Pcreate_class: class name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class: class name not pinned"); if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, (H5P_cls_create_func_t)H5P_cls_create_cb, (void *) create_data, @@ -201,6 +204,9 @@ Java_hdf_hdf5lib_H5__1H5Pcreate_1class_1nocb UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "_H5Pcreate_class_nocb: class name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "_H5Pcreate_class_nocb: class name not pinned"); if ((class_id = H5Pcreate_class((hid_t)parent_class, cstr, NULL, NULL, NULL, NULL, NULL, NULL)) < 0) @@ -239,6 +245,9 @@ Java_hdf_hdf5lib_H5_H5Pregister2 get_callback = prp_get; delete_callback = prp_delete; + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pregister2: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2: property name not pinned"); PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2: default property value buffer not pinned"); @@ -271,6 +280,9 @@ Java_hdf_hdf5lib_H5_H5Pregister2_1nocb UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pregister2_nocb: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pregister2_nocb: property name not pinned"); PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pregister2_nocb: default property value buffer not pinned"); @@ -310,6 +322,9 @@ Java_hdf_hdf5lib_H5_H5Pinsert2 get_callback = prp_get; delete_callback = prp_delete; + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pinsert2: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pinsert2: property name not pinned"); PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2: property value buffer not pinned"); @@ -342,6 +357,9 @@ Java_hdf_hdf5lib_H5_H5Pinsert2_1nocb UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pinsert2_nocb: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pinsert2_nocb: property name not pinned"); PIN_BYTE_ARRAY(ENVONLY, def_value, propValBuf, &isCopy, "H5Pinsert2_nocb: property value buffer not pinned"); @@ -370,6 +388,9 @@ Java_hdf_hdf5lib_H5_H5Pset UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pset: property name not pinned"); if ((retVal = H5Pset((hid_t)plid, cstr, &val)) < 0) @@ -396,6 +417,9 @@ Java_hdf_hdf5lib_H5_H5Pexist UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pexist: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pexist: property name not pinned"); if ((bval = H5Pexist((hid_t)plid, cstr)) < 0) @@ -425,6 +449,9 @@ Java_hdf_hdf5lib_H5_H5Pget_1size UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget_size: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pget_size: property name not pinned"); if ((status = H5Pget_size((hid_t)plid, cstr, &size)) < 0) @@ -541,6 +568,9 @@ Java_hdf_hdf5lib_H5_H5Pget UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pget: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pget: property name not pinned"); if ((status = H5Pget((hid_t)plid, cstr, &val)) < 0) @@ -629,6 +659,9 @@ Java_hdf_hdf5lib_H5_H5Pcopy_1prop UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pcopy_prop: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Pcopy_prop: property name not pinned"); if ((retVal = H5Pcopy_prop((hid_t)dst_plid, (hid_t)src_plid, cstr)) < 0) @@ -655,6 +688,9 @@ Java_hdf_hdf5lib_H5_H5Premove UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Premove: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Premove: property name not pinned"); if ((retVal = H5Premove((hid_t)plid, cstr)) < 0) @@ -681,6 +717,9 @@ Java_hdf_hdf5lib_H5_H5Punregister UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Punregister: property name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, cstr, NULL, "H5Punregister: property name not pinned"); if ((retVal = H5Punregister((hid_t)plid, cstr)) < 0) diff --git a/java/src/jni/h5pLAPLImp.c b/java/src/jni/h5pLAPLImp.c index c4502d5..f2cb80a 100644 --- a/java/src/jni/h5pLAPLImp.c +++ b/java/src/jni/h5pLAPLImp.c @@ -96,6 +96,9 @@ Java_hdf_hdf5lib_H5_H5Pset_1elink_1prefix UNUSED(clss); + if (NULL == prefix) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Pset_elink_prefix: prefix is NULL"); + PIN_JAVA_STRING(ENVONLY, prefix, linkPrefix, NULL, "H5Pset_elink_prefix: link prefix not pinned"); if ((retVal = H5Pset_elink_prefix((hid_t)lapl_id, linkPrefix)) < 0) diff --git a/java/src/jni/h5plImp.c b/java/src/jni/h5plImp.c index 4e096f1..90d78fe 100644 --- a/java/src/jni/h5plImp.c +++ b/java/src/jni/h5plImp.c @@ -83,6 +83,9 @@ Java_hdf_hdf5lib_H5_H5PLappend UNUSED(clss); + if (NULL == plugin_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLappend: new path is NULL"); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLappend: new path not pinned"); if ((retVal = H5PLappend(newPath)) < 0) @@ -106,6 +109,9 @@ Java_hdf_hdf5lib_H5_H5PLprepend UNUSED(clss); + if (NULL == plugin_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLprepend: new path is NULL"); + PIN_JAVA_STRING(ENVONLY, plugin_path, newPath, NULL, "H5PLprepend: new path not pinned"); if ((retVal = H5PLprepend(newPath)) < 0) @@ -130,6 +136,9 @@ Java_hdf_hdf5lib_H5_H5PLreplace UNUSED(clss); + if (NULL == plugin_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLreplace: new path is NULL"); + if (index < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLreplace: index < 0"); @@ -157,6 +166,9 @@ Java_hdf_hdf5lib_H5_H5PLinsert UNUSED(clss); + if (NULL == plugin_path) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5PLinsert: new path is NULL"); + if (index < 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5PLinsert: index < 0"); diff --git a/java/src/jni/h5rImp.c b/java/src/jni/h5rImp.c index 9278113..83e2216 100644 --- a/java/src/jni/h5rImp.c +++ b/java/src/jni/h5rImp.c @@ -50,6 +50,8 @@ Java_hdf_hdf5lib_H5_H5Rcreate if (NULL == ref) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: reference is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Rcreate: name is NULL"); if ((refBufLen = ENVPTR->GetArrayLength(ENVONLY, ref)) < 0) { CHECK_JNI_EXCEPTION(ENVONLY, JNI_TRUE); diff --git a/java/src/jni/h5sImp.c b/java/src/jni/h5sImp.c index 67ea59d..a91dab2 100644 --- a/java/src/jni/h5sImp.c +++ b/java/src/jni/h5sImp.c @@ -510,7 +510,7 @@ Java_hdf_hdf5lib_H5_H5Sget_1simple_1extent_1type UNUSED(clss); if (space_id < 0) - H5_LIBRARY_ERROR(ENVONLY); + H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Sget_simple_extent_type: space_id < 0"); if (H5S_NO_CLASS == (retVal = H5Sget_simple_extent_type(space_id))) H5_LIBRARY_ERROR(ENVONLY); diff --git a/java/src/jni/h5tImp.c b/java/src/jni/h5tImp.c index 08ddf85..313ca8b 100644 --- a/java/src/jni/h5tImp.c +++ b/java/src/jni/h5tImp.c @@ -48,6 +48,9 @@ Java_hdf_hdf5lib_H5__1H5Topen2 UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Topen2: datatype name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Topen2: datatype name not pinned"); if ((status = H5Topen2((hid_t)loc_id, datatypeName, (hid_t)access_plist)) < 0) @@ -855,7 +858,10 @@ Java_hdf_hdf5lib_H5_H5Tget_1member_1index UNUSED(clss); - PIN_JAVA_STRING(ENVONLY, field_name, datatypeName, NULL, "H5Tget_member_index: datatype name not pinned"); + if (NULL == field_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tget_member_index: field name is NULL"); + + PIN_JAVA_STRING(ENVONLY, field_name, datatypeName, NULL, "H5Tget_member_index: field name not pinned"); if ((index = H5Tget_member_index((hid_t)type_id, datatypeName)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -937,6 +943,9 @@ Java_hdf_hdf5lib_H5_H5Tinsert UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tinsert: datatype name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Tinsert: datatype name not pinned"); if ((status = H5Tinsert((hid_t)type_id, datatypeName, (size_t)off, field_id)) < 0) @@ -1023,6 +1032,9 @@ Java_hdf_hdf5lib_H5_H5Tset_1tag UNUSED(clss); + if (NULL == tag) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tset_tag: tag is NULL"); + PIN_JAVA_STRING(ENVONLY, tag, tagBuf, NULL, "H5Tset_tag: tag buffer not pinned"); if ((status = H5Tset_tag((hid_t)type, tagBuf)) < 0) @@ -1119,11 +1131,13 @@ Java_hdf_hdf5lib_H5_H5Tenum_1insert_1int UNUSED(clss); if (NULL == value) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert: value is NULL"); + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert_int: value is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert_int: member name is NULL"); - PIN_JAVA_STRING(ENVONLY, name, memberName, NULL, "H5Tenum_insert: member name not pinned"); + PIN_JAVA_STRING(ENVONLY, name, memberName, NULL, "H5Tenum_insert_int: member name not pinned"); - PIN_INT_ARRAY(ENVONLY, value, intBuf, &isCopy, "H5Tenum_insert: int buffer not pinned"); + PIN_INT_ARRAY(ENVONLY, value, intBuf, &isCopy, "H5Tenum_insert_int: int buffer not pinned"); if ((status = H5Tenum_insert((hid_t)type_id, memberName, intBuf)) < 0) H5_LIBRARY_ERROR(ENVONLY); @@ -1155,6 +1169,8 @@ Java_hdf_hdf5lib_H5_H5Tenum_1insert if (NULL == value) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert: value is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_insert: member name is NULL"); PIN_JAVA_STRING(ENVONLY, name, memberName, NULL, "H5Tenum_insert: member name not pinned"); @@ -1234,10 +1250,10 @@ Java_hdf_hdf5lib_H5_H5Tenum_1nameof UNUSED(clss); - if (NULL == value) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); if (size <= 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: name size < 0"); + if (NULL == value) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_nameof: value is NULL"); if (NULL == (nameP = (char *) HDmalloc(sizeof(char) * (size_t)size))) H5_JNI_FATAL_ERROR(ENVONLY, "H5Tenum_nameof: failed to allocate name buffer"); @@ -1278,6 +1294,8 @@ Java_hdf_hdf5lib_H5_H5Tenum_1valueof_1int if (NULL == value) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof_int: value is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof_int: enum value name is NULL"); PIN_JAVA_STRING(ENVONLY, name, enumValue, NULL, "H5Tenum_valueof_int: enum value not pinned"); @@ -1313,6 +1331,8 @@ Java_hdf_hdf5lib_H5_H5Tenum_1valueof if (NULL == value) H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof: value is NULL"); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tenum_valueof: enum value name is NULL"); PIN_JAVA_STRING(ENVONLY, name, enumValue, NULL, "H5Tenum_valueof: enum value not pinned"); @@ -1533,6 +1553,9 @@ Java_hdf_hdf5lib_H5_H5Tcommit UNUSED(clss); + if (NULL == name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tcommit: datatype name is NULL"); + PIN_JAVA_STRING(ENVONLY, name, datatypeName, NULL, "H5Tcommit: datatype name not pinned"); if ((status = H5Tcommit2((hid_t)loc_id, datatypeName, (hid_t)type, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id)) < 0) @@ -1561,10 +1584,10 @@ Java_hdf_hdf5lib_H5__1H5Tarray_1create2 UNUSED(clss); - if (NULL == dims) - H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dims is NULL"); if (rank <= 0) H5_BAD_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: rank is < 1"); + if (NULL == dims) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5Tarray_create: dims is NULL"); PIN_LONG_ARRAY(ENVONLY, dims, dimsP, &isCopy, "H5Tarray_create: dimsP not pinned"); diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 4208ce1..fce969e 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -232,7 +232,7 @@ h5str_convert HDmemcpy(cptr, &tmp_double, sizeof(double)); break; } -#if H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { long double tmp_ldouble = 0.0; @@ -259,6 +259,8 @@ h5str_convert if (len > 0) { HDstrncpy(cptr, this_str, typeSize); + cptr[typeSize - 1] = '\0'; + retVal = typeSize; } else { @@ -329,6 +331,7 @@ h5str_convert break; } +#if H5_SIZEOF_LONG != H5_SIZEOF_INT case sizeof(long): { unsigned long tmp_ulong = 0; @@ -345,7 +348,7 @@ h5str_convert break; } - +#endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG case sizeof(long long): { @@ -444,14 +447,14 @@ h5str_convert value = &tmp_ushort; break; } - +#if H5_SIZEOF_LONG != H5_SIZEOF_INT case sizeof(long): { unsigned long tmp_ulong = 0; value = &tmp_ulong; break; } - +#endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG case sizeof(long long): { @@ -694,7 +697,7 @@ h5str_sprintf break; } -#if H5_SIZEOF_LONG_DOUBLE != 0 +#if H5_SIZEOF_LONG_DOUBLE != 0 && H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE case sizeof(long double): { long double tmp_ldouble = 0.0; @@ -750,6 +753,7 @@ h5str_sprintf H5_JNI_FATAL_ERROR(ENVONLY, "h5str_sprintf: failed to allocate string buffer"); HDstrncpy(this_str, tmp_str, typeSize); + this_str[typeSize] = '\0'; } } @@ -844,7 +848,7 @@ h5str_sprintf break; } - +#if H5_SIZEOF_LONG != H5_SIZEOF_INT case sizeof(long): { unsigned long tmp_ulong = 0; @@ -871,7 +875,7 @@ h5str_sprintf break; } - +#endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG case sizeof(long long): { diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c index c816abf..92e456e 100644 --- a/java/src/jni/h5vlImp.c +++ b/java/src/jni/h5vlImp.c @@ -41,6 +41,9 @@ Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name UNUSED(clss); + if (NULL == connector_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLregister_connector_by_name: VOL connector name is NULL"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLregister_connector_by_name: VOL connector name not pinned"); if ((status = H5VLregister_connector_by_name(volName, (hid_t)vipl_id)) < 0) @@ -87,6 +90,9 @@ Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered UNUSED(clss); + if (NULL == connector_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLis_connector_registered: VOL connector name is NULL"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLis_connector_registered: VOL connector name not pinned"); if ((bval = H5VLis_connector_registered(volName)) < 0) @@ -115,6 +121,9 @@ Java_hdf_hdf5lib_H5_H5VLget_1connector_1id UNUSED(clss); + if (NULL == connector_name) + H5_NULL_ARGUMENT_ERROR(ENVONLY, "H5VLget_connector_id: VOL connector name is NULL"); + PIN_JAVA_STRING(ENVONLY, connector_name, volName, NULL, "H5VLget_connector_id: VOL connector name not pinned"); if ((status = H5VLget_connector_id(volName)) < 0) diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java index 591793f..ee2850b 100644 --- a/java/test/TestH5Edefault.java +++ b/java/test/TestH5Edefault.java @@ -243,7 +243,7 @@ public class TestH5Edefault { H5.H5Eget_class_name(-1); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = HDF5LibraryException.class) public void testH5Eget_class_name_invalid_classname() throws Throwable { H5.H5Eget_class_name(HDF5Constants.H5E_DEFAULT); } diff --git a/java/test/TestH5Oparams.java b/java/test/TestH5Oparams.java index 8b3c673..d340ee7 100644 --- a/java/test/TestH5Oparams.java +++ b/java/test/TestH5Oparams.java @@ -124,7 +124,7 @@ public class TestH5Oparams { H5.H5Oset_comment(-1, "Bogus"); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = HDF5LibraryException.class) public void testH5Oget_comment_invalid() throws Throwable { H5.H5Oget_comment(-1); } @@ -139,7 +139,7 @@ public class TestH5Oparams { H5.H5Oset_comment_by_name(-1, null, null, -1); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = HDF5LibraryException.class) public void testH5Oget_comment_by_name_invalid() throws Throwable { H5.H5Oget_comment_by_name(-1, "Bogus", -1); } diff --git a/java/test/TestH5Sbasic.java b/java/test/TestH5Sbasic.java index 3007495..2173647 100644 --- a/java/test/TestH5Sbasic.java +++ b/java/test/TestH5Sbasic.java @@ -49,7 +49,7 @@ public class TestH5Sbasic { H5.H5Screate(-1); } - @Test(expected = HDF5LibraryException.class) + @Test(expected = IllegalArgumentException.class) public void testH5Sget_simple_extent_type_invalid() throws Throwable { H5.H5Sget_simple_extent_type(-1); } -- cgit v0.12 From 8c22f4180195b63b77c5b27a704b8158a422b793 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 12 Feb 2019 15:51:42 -0600 Subject: KNL option for batch scripts --- config/cmake/scripts/HPC/sbatch-HDF5options.cmake | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake index 5316f41..dc97b3a 100644 --- a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake +++ b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake @@ -28,22 +28,24 @@ if (DEFINED MPI) endif () ############################################################################################# ### options to run test scripts in batch commands +if (DEFINED KNL) + ### some additions and alternatives to cross compile on haswell for knl + set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") + set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") + set (LOCAL_BATCH_SCRIPT_NAME "knl_ctestS.sl") + set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "knl_ctestP.sl") +else () + set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") + set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") +endif () set (LOCAL_BATCH_SCRIPT_COMMAND "sbatch") set (LOCAL_BATCH_TEST "TRUE") -set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") -set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.sl") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.sl") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=${LOCAL_BATCH_SCRIPT_NAME}") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=${LOCAL_BATCH_SCRIPT_PARALLEL_NAME}") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") ############################################################################################# -### some additions and alternatives to cross compile on haswell for knl -#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") -#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") -#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") ############################################################################################# -- cgit v0.12 From b5305b25a67c41f0d87352d39e799b603ed10c69 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 12 Feb 2019 21:51:15 -0600 Subject: Align develop with incoming hyperslab_updates branch changes. --- src/H5CX.c | 2 +- src/H5Dchunk.c | 89 ++-- src/H5Dmpio.c | 72 +-- src/H5Osdspace.c | 8 +- src/H5S.c | 391 +++++----------- src/H5Sall.c | 100 ++-- src/H5Sdbg.c | 10 +- src/H5Shyper.c | 354 +++++++------- src/H5Smpio.c | 811 +++++++++++++++------------------ src/H5Snone.c | 393 ++++++++-------- src/H5Spkg.h | 23 +- src/H5Spoint.c | 503 ++++++++++---------- src/H5Sprivate.h | 24 +- src/H5Spublic.h | 69 ++- src/H5Sselect.c | 319 ++++++++----- src/H5Stest.c | 57 ++- test/objcopy.c | 4 +- test/tselect.c | 1214 +++++++++++++++++++++++++------------------------ testpar/t_shapesame.c | 32 +- testpar/t_span_tree.c | 28 +- 20 files changed, 2256 insertions(+), 2247 deletions(-) diff --git a/src/H5CX.c b/src/H5CX.c index f945df0..d90fec1 100644 --- a/src/H5CX.c +++ b/src/H5CX.c @@ -53,7 +53,7 @@ * each thread individually. The association of contexts to threads will * be handled by the pthread library. * - * In order for this macro to work, H5E__get_my_stack() must be preceeded + * In order for this macro to work, H5CX_get_my_context() must be preceeded * by "H5CX_node_t *ctx =". */ #define H5CX_get_my_context() H5CX__get_context() diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index af8ff91..6d1067b 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -1073,21 +1073,19 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf 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++) { + /* Decide the number of chunks in each dimension */ + 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]; - } /* end for */ #ifdef H5_HAVE_PARALLEL /* Calculate total chunk in file map*/ fm->select_chunk = NULL; 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(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 */ #endif /* H5_HAVE_PARALLEL */ @@ -1129,10 +1127,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf 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) 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") - } /* end if */ fm->single_chunk_info = dataset->shared->cache.chunk.single_chunk_info; HDassert(fm->single_chunk_info); @@ -1147,10 +1144,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf 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) 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") - } /* end if */ fm->sel_chunks = dataset->shared->cache.chunk.sel_chunks; HDassert(fm->sel_chunks); @@ -1245,10 +1241,9 @@ H5D__chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_inf fm->mchunk_tmpl = tmp_mspace; /* Create temporary datatypes for selection iteration */ - if(!file_type) { + 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") - } /* end if */ /* Create selection iterator for memory selection */ if(0 == (elmt_size = H5T_get_size(mem_type))) @@ -1540,7 +1535,7 @@ done: /*------------------------------------------------------------------------- * Function: H5D__create_chunk_file_map_hyper * - * Purpose: Create all chunk selections in file. + * Purpose: Create all chunk selections in file, for a hyperslab selection. * * Return: Non-negative on success/Negative on failure * @@ -1556,8 +1551,8 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t #endif /* H5_HAVE_PARALLEL */ *io_info) { - 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_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 */ @@ -1572,7 +1567,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t FUNC_ENTER_STATIC /* Sanity check */ - HDassert(fm->f_ndims>0); + HDassert(fm->f_ndims > 0); /* Get number of elements selected in file */ sel_points = fm->nelmts; @@ -1596,7 +1591,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Iterate through each chunk in the dataset */ while(sel_points) { - /* Check for intersection of temporary chunk and file selection */ + /* Check for intersection of current chunk and file selection */ /* (Casting away const OK - QAK) */ if(TRUE == H5S_hyper_intersect_block((H5S_t *)fm->file_space, coords, end)) { H5S_t *tmp_fchunk; /* Temporary file dataspace */ @@ -1634,7 +1629,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* 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))) { (void)H5S_close(tmp_fchunk); HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate chunk info") } /* end if */ @@ -1642,7 +1637,7 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Initialize the chunk information */ /* Set the chunk index */ - new_chunk_info->index=chunk_index; + new_chunk_info->index = chunk_index; #ifdef H5_HAVE_PARALLEL /* Store chunk selection information, for multi-chunk I/O */ @@ -1655,16 +1650,13 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t new_chunk_info->fspace_shared = FALSE; /* 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 */ HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); new_chunk_info->scaled[fm->f_ndims] = 0; - /* Copy the chunk's scaled coordinates */ - HDmemcpy(new_chunk_info->scaled, scaled, sizeof(hsize_t) * fm->f_ndims); - /* Insert the new chunk into the skip list */ if(H5SL_insert(fm->sel_chunks, new_chunk_info, &new_chunk_info->index) < 0) { H5D__free_chunk_info(new_chunk_info, NULL, NULL); @@ -1688,12 +1680,11 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t chunk_index++; /* Set current increment dimension */ - curr_dim=(int)fm->f_ndims-1; + curr_dim = (int)fm->f_ndims - 1; /* Increment chunk location in fastest changing dimension */ - H5_CHECK_OVERFLOW(fm->chunk_dim[curr_dim],hsize_t,hssize_t); - coords[curr_dim]+=fm->chunk_dim[curr_dim]; - end[curr_dim]+=fm->chunk_dim[curr_dim]; + coords[curr_dim] += fm->chunk_dim[curr_dim]; + end[curr_dim] += fm->chunk_dim[curr_dim]; scaled[curr_dim]++; /* Bring chunk location back into bounds, if necessary */ @@ -1707,11 +1698,14 @@ H5D__create_chunk_file_map_hyper(H5D_chunk_map_t *fm, const H5D_io_info_t /* Decrement current dimension */ curr_dim--; - /* 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; - } while(coords[curr_dim] > sel_end[curr_dim]); + /* Check for valid current dim */ + 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])); /* Re-calculate the index of this chunk */ chunk_index = H5VM_array_offset_pre(fm->f_ndims, fm->layout->u.chunk.down_chunks, scaled); @@ -1743,12 +1737,12 @@ static herr_t H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) { H5SL_node_t *curr_node; /* Current node in skip list */ - hsize_t file_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ - hsize_t file_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ - hsize_t mem_sel_start[H5O_LAYOUT_NDIMS]; /* Offset of low bound of file selection */ - hsize_t mem_sel_end[H5O_LAYOUT_NDIMS]; /* Offset of high bound of file selection */ - hssize_t adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to all file chunks */ - hssize_t chunk_adjust[H5O_LAYOUT_NDIMS]; /* Adjustment to make to a particular chunk */ + 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 */ + hssize_t chunk_adjust[H5S_MAX_RANK]; /* Adjustment to make to a particular chunk */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1762,7 +1756,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ /* Get the node */ - curr_node=H5SL_first(fm->sel_chunks); + curr_node = H5SL_first(fm->sel_chunks); /* Get pointer to chunk's information */ chunk_info = (H5D_chunk_info_t *)H5SL_item(curr_node); @@ -1785,15 +1779,15 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) 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; uf_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]; + HDassert(fm->m_ndims == fm->f_ndims); + 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]; } /* end for */ /* Iterate over each chunk in the chunk list */ - curr_node=H5SL_first(fm->sel_chunks); + curr_node = H5SL_first(fm->sel_chunks); while(curr_node) { H5D_chunk_info_t *chunk_info; /* Pointer to chunk information */ @@ -1832,7 +1826,7 @@ H5D__create_chunk_mem_map_hyper(const H5D_chunk_map_t *fm) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to adjust selection") /* Get the next chunk node in the skip list */ - curr_node=H5SL_next(curr_node); + curr_node = H5SL_next(curr_node); } /* end while */ } /* end else */ @@ -1976,7 +1970,7 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u { 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[H5O_LAYOUT_NDIMS]; /* Coordinates of element in memory */ + 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 */ @@ -2001,11 +1995,10 @@ H5D__chunk_mem_cb(void H5_ATTR_UNUSED *elem, const H5T_t H5_ATTR_UNUSED *type, u 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))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, H5_ITER_ERROR, "unable to copy file space") - } /* end else */ /* Update the "last chunk seen" information */ fm->last_index = chunk_index; diff --git a/src/H5Dmpio.c b/src/H5Dmpio.c index 0423006..01cf932 100644 --- a/src/H5Dmpio.c +++ b/src/H5Dmpio.c @@ -2841,30 +2841,30 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty 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") - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") 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))) + 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) + if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; @@ -2875,11 +2875,11 @@ H5D__chunk_redistribute_shared_chunks(const H5D_io_info_t *io_info, const H5D_ty /* 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, + 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; @@ -3048,11 +3048,11 @@ 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) @@ -3170,7 +3170,7 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk 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) + if(H5S_select_iter_init(mem_iter, chunk_info->mspace, type_info->src_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; @@ -3180,53 +3180,53 @@ 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) + if(H5S_select_iter_init(file_iter, chunk_info->fspace, type_info->src_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") file_iter_init = TRUE; - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - if (NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size))) + if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) 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, chunk_info->fspace, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) + if(!H5D__gather_mem(chunk_entry->buf, chunk_info->fspace, file_iter, (size_t) iter_nelmts, tmp_gath_buf)) HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "couldn't gather from chunk buffer") - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - if (H5D__scatter_mem(tmp_gath_buf, chunk_info->mspace, mem_iter, (size_t) iter_nelmts, io_info->u.rbuf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "couldn't scatter to read buffer") + if(H5D__scatter_mem(tmp_gath_buf, chunk_info->mspace, 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; case H5D_IO_OP_WRITE: - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->mspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") - if (NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) iter_nelmts * type_info->src_type_size))) + if(NULL == (tmp_gath_buf = H5MM_malloc((hsize_t) 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(!H5D__gather_mem(io_info->u.wbuf, chunk_info->mspace, 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) + if(H5S_select_iter_init(mem_iter, chunk_info->fspace, type_info->dst_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize file selection information") mem_iter_init = TRUE; - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(chunk_info->fspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") /* Scatter the owner's modification data into the chunk data buffer according to @@ -3235,44 +3235,44 @@ H5D__filtered_collective_chunk_entry_io(H5D_filtered_collective_io_info_t *chunk if(H5D__scatter_mem(tmp_gath_buf, chunk_info->fspace, 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, + 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) + if(H5S_select_iter_init(mem_iter, dataspace, type_info->dst_type_size) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize memory selection information") mem_iter_init = TRUE; - if ((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0) + if((iter_nelmts = H5S_GET_SELECT_NPOINTS(dataspace)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "dataspace is invalid") /* Update the chunk data with the received modification data */ if(H5D__scatter_mem(mod_data_p, dataspace, 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; - } + } /* end if */ H5MM_free(chunk_entry->async_info.receive_buffer_array[i]); } /* end for */ diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 74fa72e..b7f70d1 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -189,7 +189,7 @@ H5O__sdspace_decode(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, done: if(!ret_value && sdim) { - H5S_extent_release(sdim); + H5S__extent_release(sdim); sdim = H5FL_FREE(H5S_extent_t, sdim); } /* end if */ @@ -310,7 +310,7 @@ H5O_sdspace_copy(const void *_mesg, void *_dest) 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 */ @@ -391,7 +391,7 @@ H5O__sdspace_reset(void *_mesg) FUNC_ENTER_STATIC_NOERR - H5S_extent_release(mesg); + H5S__extent_release(mesg); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O__sdspace_reset() */ @@ -470,7 +470,7 @@ H5O_sdspace_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src, 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 */ diff --git a/src/H5S.c b/src/H5S.c index 2faf540..3a917bc 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -46,7 +46,12 @@ /********************/ /* Local Prototypes */ /********************/ -static htri_t H5S_is_simple(const H5S_t *sdim); +static htri_t H5S__is_simple(const H5S_t *sdim); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ /*********************/ @@ -63,15 +68,6 @@ const unsigned H5O_sdspace_ver_bounds[] = { H5O_SDSPACE_VERSION_LATEST /* H5F_LIBVER_LATEST */ }; -/*****************************/ -/* Library Private Variables */ -/*****************************/ - - -/*******************/ -/* Local Variables */ -/*******************/ - /* Declare a free list to manage the H5S_extent_t struct */ H5FL_DEFINE(H5S_extent_t); @@ -81,6 +77,11 @@ 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 */ @@ -112,9 +113,9 @@ H5S__init_package(void) FUNC_ENTER_PACKAGE - /* Initialize the atom group for the file IDs */ + /* Initialize the atom group for the dataspace IDs */ if(H5I_register_type(H5I_DATASPACE_CLS) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize interface") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize dataspace ID class") /* Mark "top" of interface as initialized, too */ H5S_top_package_initialize_s = TRUE; @@ -329,10 +330,9 @@ H5S_create(H5S_class_t type) ret_value = new_ds; done: - if(ret_value == NULL) { + if(ret_value == NULL) if(new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, NULL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_create() */ @@ -359,7 +359,7 @@ done: hid_t H5Screate(H5S_class_t type) { - H5S_t *new_ds=NULL; /* New dataspace structure */ + H5S_t *new_ds = NULL; /* New dataspace structure */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -373,21 +373,20 @@ H5Screate(H5S_class_t 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(ret_value < 0) if(new_ds && H5S_close(new_ds) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Screate() */ /*------------------------------------------------------------------------- - * Function: H5S_extent_release + * Function: H5S__extent_release * * Purpose: Releases all memory associated with a dataspace extent. * @@ -396,16 +395,12 @@ done: * Programmer: Quincey Koziol * Thursday, July 23, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5S_extent_release(H5S_extent_t *extent) +H5S__extent_release(H5S_extent_t *extent) { - herr_t ret_value=SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE_NOERR HDassert(extent); @@ -417,9 +412,8 @@ H5S_extent_release(H5S_extent_t *extent) extent->max = H5FL_ARR_FREE(hsize_t, extent->max); } /* end if */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_extent_release() */ + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5S__extent_release() */ /*------------------------------------------------------------------------- @@ -445,11 +439,11 @@ H5S_close(H5S_t *ds) /* Release selection (this should come before the extent release) */ if(H5S_SELECT_RELEASE(ds) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace selection") /* Release extent */ - if(H5S_extent_release(&ds->extent) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") + if(H5S__extent_release(&ds->extent) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace extent") /* Release the main structure */ ds = H5FL_FREE(H5S_t, ds); @@ -466,13 +460,9 @@ done: * * Return: Non-negative on success/Negative on failure * - * Errors: - * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -484,7 +474,7 @@ H5Sclose(hid_t space_id) 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 */ @@ -502,14 +492,11 @@ done: * Purpose: Copies a dataspace. * * Return: Success: ID of the new dataspace - * * Failure: Negative * * Programmer: Robb Matzke * Friday, January 30, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ hid_t @@ -535,10 +522,9 @@ H5Scopy(hid_t space_id) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") done: - if(ret_value < 0) { + if(ret_value < 0) if(dst && H5S_close(dst) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Scopy() */ @@ -554,8 +540,6 @@ done: * Programmer: Quincey Koziol * Thursday, July 23, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -593,8 +577,6 @@ done: * Programmer: Neil Fortner * Monday, February 23, 2015 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -608,7 +590,7 @@ 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 @@ -623,7 +605,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_extent_copy_real + * Function: H5S__extent_copy_real * * Purpose: Copies a dataspace extent * @@ -632,20 +614,18 @@ done: * Programmer: Quincey Koziol * Wednesday, June 3, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t -H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_max) +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 */ - FUNC_ENTER_NOAPI(FAIL) + 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 */ @@ -690,7 +670,7 @@ H5S_extent_copy_real(H5S_extent_t *dst, const H5S_extent_t *src, hbool_t copy_ma done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_extent_copy_real() */ +} /* end H5S__extent_copy_real() */ /*------------------------------------------------------------------------- @@ -704,14 +684,11 @@ done: * selection) * * Return: Success: A pointer to a new copy of SRC - * * Failure: NULL * * Programmer: Robb Matzke * Thursday, December 4, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ H5S_t * @@ -726,7 +703,7 @@ H5S_copy(const H5S_t *src, hbool_t share_selection, hbool_t copy_max) 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 */ @@ -751,7 +728,6 @@ done: * Purpose: Determines how many data points a dataset extent has. * * Return: Success: Number of data points in the dataset extent. - * * Failure: negative * * Programmer: Robb Matzke @@ -761,9 +737,6 @@ done: * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * Changed Name - QAK 7/7/98 - * *------------------------------------------------------------------------- */ hssize_t @@ -790,15 +763,11 @@ done: * Purpose: Determines how many data points a dataset extent has. * * Return: Success: Number of data points in the dataset. - * * Failure: negative * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Modifications: - * Changed Name - QAK 7/7/98 - * *------------------------------------------------------------------------- */ hssize_t @@ -832,14 +801,11 @@ done: * * Return: Success: Maximum number of data points the dataspace * may have. - * * Failure: 0 * * Programmer: Robb Matzke * Tuesday, December 9, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ hsize_t @@ -853,7 +819,7 @@ H5S_get_npoints_max(const H5S_t *ds) /* check args */ HDassert(ds); - switch (H5S_GET_EXTENT_TYPE(ds)) { + switch(H5S_GET_EXTENT_TYPE(ds)) { case H5S_NULL: ret_value = 0; break; @@ -863,31 +829,30 @@ H5S_get_npoints_max(const H5S_t *ds) break; case H5S_SIMPLE: - if (ds->extent.max) { - for (ret_value=1, u=0; uextent.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; - } + } /* end if */ else ret_value *= ds->extent.max[u]; - } - } - else { - for (ret_value=1, u=0; uextent.rank; u++) + } /* end for */ + } /* end if */ + else + for(ret_value = 1, u = 0; u < ds->extent.rank; u++) ret_value *= ds->extent.size[u]; - } break; case H5S_NO_CLASS: default: HDassert("unknown dataspace class" && 0); HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0, "internal error (unknown dataspace class)") - } + } /* end switch */ done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5S_get_npoints_max() */ /*------------------------------------------------------------------------- @@ -896,21 +861,18 @@ done: * Purpose: Determines the dimensionality of a dataspace. * * Return: Success: The number of dimensions in a dataspace. - * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ int H5Sget_simple_extent_ndims(hid_t space_id) { - H5S_t *ds; - int ret_value; + H5S_t *ds; + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", space_id); @@ -933,7 +895,6 @@ done: * * Return: Success: Non-negative number of dimensions. Zero * implies a scalar. - * * Failure: Negative * * Programmer: Robb Matzke @@ -943,8 +904,6 @@ done: * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -979,43 +938,36 @@ done: * Function: H5Sget_simple_extent_dims * * Purpose: Returns the size and maximum sizes in each dimension of - * a dataspace DS through the DIMS and MAXDIMS arguments. + * a dataspace DS through the DIMS and MAXDIMS arguments. * * Return: Success: Number of dimensions, the same value as * returned by H5Sget_simple_extent_ndims(). - * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * - * Modifications: - * June 18, 1998 Albert Cheng - * Added maxdims argument. Removed dims argument check - * since it can still return ndims even if both dims and - * maxdims are NULLs. - * *------------------------------------------------------------------------- */ int H5Sget_simple_extent_dims(hid_t space_id, hsize_t dims[]/*out*/, - hsize_t maxdims[]/*out*/) + hsize_t maxdims[]/*out*/) { - H5S_t *ds; - int ret_value; + H5S_t *ds; + int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) 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, FAIL, "not a dataspace") ret_value = H5S_get_simple_extent_dims(ds, dims, maxdims); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sget_simple_extent_dims() */ /*------------------------------------------------------------------------- @@ -1081,14 +1033,11 @@ done: * function may not be meaningful for all types of dataspaces. * * Return: Success: Number of dimensions. Zero implies scalar. - * * Failure: Negative * * Programmer: Robb Matzke * Thursday, December 11, 1997 * - * Modifications: - * *------------------------------------------------------------------------- */ int @@ -1155,13 +1104,6 @@ done: * Programmer: Quincey Koziol * Tuesday, December 31, 2002 * - * Modifications: - * - * John Mainzer, 6/6/05 - * Updated function to use the new dirtied parameter of - * H5AC_unprotect() instead of manipulating the is_dirty - * field of the cache info. - * *------------------------------------------------------------------------- */ herr_t @@ -1191,7 +1133,6 @@ done: * Purpose: Reads the dataspace from an object header. * * Return: Success: Pointer to a new dataspace. - * * Failure: NULL * * Programmer: Robb Matzke @@ -1224,10 +1165,9 @@ H5S_read(const H5O_loc_t *loc) ret_value = ds; done: - if(ret_value == NULL) { + if(ret_value == NULL) if(ds != NULL) ds = H5FL_FREE(H5S_t, ds); - } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5S_read() */ @@ -1235,11 +1175,11 @@ done: /*-------------------------------------------------------------------------- NAME - H5S_is_simple + H5S__is_simple PURPOSE Check if a dataspace is simple (internal) USAGE - htri_t H5S_is_simple(sdim) + htri_t H5S__is_simple(sdim) H5S_t *sdim; IN: Pointer to dataspace object to query RETURNS TRUE/FALSE/FAIL @@ -1248,21 +1188,21 @@ done: has orthogonal, evenly spaced dimensions. --------------------------------------------------------------------------*/ static htri_t -H5S_is_simple(const H5S_t *sdim) +H5S__is_simple(const H5S_t *sdim) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args and all the boring stuff. */ 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; + H5S_GET_EXTENT_TYPE(sdim) == H5S_SCALAR) ? TRUE : FALSE; FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_is_simple() */ +} /* end H5S__is_simple() */ /*-------------------------------------------------------------------------- @@ -1282,21 +1222,21 @@ H5S_is_simple(const H5S_t *sdim) htri_t H5Sis_simple(hid_t space_id) { - H5S_t *space; /* dataspace to modify */ - htri_t ret_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 ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) + 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); + ret_value = H5S__is_simple(space); - done: +done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sis_simple() */ /*-------------------------------------------------------------------------- @@ -1324,56 +1264,44 @@ H5Sis_simple(hid_t space_id) Currently, only the first dimension in the array (the slowest) may be unlimited in size. - MODIFICATION - A null dataspace cannot be created from simple space with this function. - - Christian Chilan 01/17/2007 - Verifies that each element of DIMS is not equal to H5S_UNLIMITED. - - Raymond Lu 03/30/2011 - We allow 0 dimension size for non-unlimited dimension starting from 1.8.7 - release. --------------------------------------------------------------------------*/ herr_t H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/], - const hsize_t max[/*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 ((space = (H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE)) == NULL) + 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; uextent) < 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 */ @@ -1432,12 +1358,11 @@ 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) HDmemcpy(space->extent.max, max, sizeof(hsize_t) * rank); - } else { + else for(u = 0; u < space->extent.rank; u++) space->extent.max[u] = dims[u]; - } } /* end else */ /* Selection related cleanup */ @@ -1453,7 +1378,7 @@ H5S_set_extent_simple(H5S_t *space, unsigned rank, const hsize_t *dims, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_set_extent_simple() */ +} /* end H5S_set_extent_simple() */ /*------------------------------------------------------------------------- @@ -1469,26 +1394,20 @@ done: * than the corresponding element of DIMS. * * Return: Success: The ID for the new simple dataspace object. - * * Failure: Negative * * Programmer: Quincey Koziol * Tuesday, January 27, 1998 * - * Modification: - * Raymond Lu 03/30/2011 - * We allow 0-dimension for non-unlimited dimension starting - * from 1.8.7 release. - * *------------------------------------------------------------------------- */ hid_t H5Screate_simple(int rank, const hsize_t dims[/*rank*/], - const hsize_t maxdims[/*rank*/]) + const hsize_t maxdims[/*rank*/]) { H5S_t *space = NULL; int i; - hid_t ret_value; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "Is*[a0]h*[a0]h", rank, dims, maxdims); @@ -1514,7 +1433,7 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/], } /* end for */ /* Create the space and set the extent */ - if(NULL == (space = H5S_create_simple((unsigned)rank,dims,maxdims))) + if(NULL == (space = H5S_create_simple((unsigned)rank, dims, maxdims))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") /* Atomize */ @@ -1522,10 +1441,9 @@ H5Screate_simple(int rank, const hsize_t dims[/*rank*/], HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace ID") done: - if(ret_value < 0) { + if(ret_value < 0) if(space && H5S_close(space) < 0) HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Screate_simple() */ @@ -1539,32 +1457,26 @@ done: * Return: Success: The ID for the new simple dataspace object. * Failure: Negative * - * Errors: - * * Programmer: Quincey Koziol * Thursday, April 3, 2003 * - * Modifications: - * Extracted from H5Screate_simple - * Quincey Koziol, Thursday, April 3, 2003 - * *------------------------------------------------------------------------- */ H5S_t * H5S_create_simple(unsigned rank, const hsize_t dims[/*rank*/], - const hsize_t maxdims[/*rank*/]) + const hsize_t maxdims[/*rank*/]) { H5S_t *ret_value = NULL; /* Return value */ FUNC_ENTER_NOAPI(NULL) /* Check arguments */ - HDassert(rank <=H5S_MAX_RANK); + HDassert(rank <= H5S_MAX_RANK); /* Create the space and set the extent */ - if(NULL==(ret_value=H5S_create(H5S_SIMPLE))) + if(NULL == (ret_value = H5S_create(H5S_SIMPLE))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, NULL, "can't create simple dataspace") - if(H5S_set_extent_simple(ret_value,rank,dims,maxdims)<0) + if(H5S_set_extent_simple(ret_value, rank, dims, maxdims) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, NULL, "can't set dimensions") done: @@ -1579,15 +1491,12 @@ done: * (including selection) into binary in a buffer. * * Return: Success: non-negative - * * Failure: negative * * Programmer: Raymond Lu * slu@ncsa.uiuc.edu * July 14, 2004 * - * Modifications: - * *------------------------------------------------------------------------- */ herr_t @@ -1600,15 +1509,15 @@ H5Sencode(hid_t obj_id, void *buf, size_t *nalloc) 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))) + if(NULL == (dspace = (H5S_t *)H5I_object_verify(obj_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if(H5S_encode(dspace, (unsigned char **)&buf, nalloc)<0) + 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) -} +} /* end H5Sencode() */ /*------------------------------------------------------------------------- @@ -1697,7 +1606,6 @@ done: * return a new object handle. * * Return: Success: dataspace ID(non-negative) - * * Failure: negative * * Programmer: Raymond Lu @@ -1737,7 +1645,6 @@ done: * description of dataspace and returns a new object handle. * * Return: Success: dataspace ID(non-negative) - * * Failure: negative * * Programmer: Raymond Lu @@ -1784,11 +1691,11 @@ H5S_decode(const unsigned char **p) pp += extent_size; /* Copy the extent into dataspace structure */ - if((ds = H5FL_CALLOC(H5S_t))==NULL) + if(NULL == (ds = H5FL_CALLOC(H5S_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for dataspace conversion path table") - if(H5O_msg_copy(H5O_SDSPACE_ID, extent, &(ds->extent)) == NULL) + 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); @@ -1819,11 +1726,8 @@ done: * Purpose: Internal function for retrieving the type of extent for a dataspace object * * Return: Success: The class of the dataspace object - * * Failure: N5S_NO_CLASS * - * Errors: - * * Programmer: Quincey Koziol * Thursday, September 28, 2000 * @@ -1831,8 +1735,6 @@ done: * pattern, don't call it directly, use the appropriate macro * defined in H5Sprivate.h. * - * Modifications: - * *------------------------------------------------------------------------- */ H5S_class_t @@ -1844,11 +1746,11 @@ H5S_get_simple_extent_type(const H5S_t *space) HDassert(space); - ret_value=H5S_GET_EXTENT_TYPE(space); + ret_value = H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5S_get_simple_extent_type() */ /*------------------------------------------------------------------------- @@ -1857,36 +1759,31 @@ done: * Purpose: Retrieves the type of extent for a dataspace object * * Return: Success: The class of the dataspace object - * * Failure: N5S_NO_CLASS * - * Errors: - * * Programmer: Quincey Koziol * Thursday, July 23, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ H5S_class_t H5Sget_simple_extent_type(hid_t sid) { H5S_t *space; - H5S_class_t ret_value; + 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); + ret_value = H5S_GET_EXTENT_TYPE(space); done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Sget_simple_extent_type() */ /*-------------------------------------------------------------------------- @@ -1906,68 +1803,25 @@ done: 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_NO_CLASS; - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Sset_extent_none() */ - - -/*-------------------------------------------------------------------------- - NAME - H5Soffset_simple - PURPOSE - Changes the offset of a selection within a simple dataspace extent - USAGE - herr_t H5Soffset_simple(space_id, offset) - hid_t space_id; IN: Dataspace object to reset - const hssize_t *offset; IN: Offset to position the selection at - RETURNS - Non-negative on success/Negative on failure - DESCRIPTION - 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 */ - - 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))) - 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)) - HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") - if (offset == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified") - - /* Set the selection offset */ - if(H5S_select_offset(space,offset)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set offset") + space->extent.type = H5S_NO_CLASS; done: FUNC_LEAVE_API(ret_value) -} /* end H5Soffset_simple() */ +} /* end H5Sset_extent_none() */ /*------------------------------------------------------------------------- @@ -1996,7 +1850,7 @@ 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++) { + 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] && @@ -2006,7 +1860,6 @@ H5S_set_extent(H5S_t *space, const hsize_t *size) /* Indicate that dimension size can be modified */ ret_value = TRUE; } /* end if */ - } /* end for */ /* Update dimension size(s) */ if(ret_value) @@ -2033,7 +1886,7 @@ done: * *------------------------------------------------------------------------- */ -hbool_t +H5_ATTR_PURE hbool_t H5S_has_extent(const H5S_t *ds) { hbool_t ret_value = FALSE; /* Return value */ @@ -2104,7 +1957,6 @@ done: * Purpose: Determines if two dataspace extents are equal. * * Return: Success: TRUE if equal, FALSE if unequal - * * Failure: Negative * * Programmer: Quincey Koziol @@ -2116,7 +1968,7 @@ htri_t H5Sextent_equal(hid_t space1_id, hid_t space2_id) { const H5S_t *ds1, *ds2; /* Dataspaces to compare */ - htri_t ret_value; + htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("t", "ii", space1_id, space2_id); @@ -2148,7 +2000,7 @@ done: DESCRIPTION Compare two dataspaces if their extents are identical. --------------------------------------------------------------------------*/ -htri_t +H5_ATTR_PURE htri_t H5S_extent_equal(const H5S_t *ds1, const H5S_t *ds2) { unsigned u; /* Local index variable */ @@ -2209,7 +2061,7 @@ done: * *------------------------------------------------------------------------- */ -hsize_t +H5_ATTR_PURE hsize_t H5S_extent_nelem(const H5S_extent_t *ext) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -2257,6 +2109,5 @@ H5S_set_version(H5F_t *f, H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) - } /* end H5S_set_version() */ diff --git a/src/H5Sall.c b/src/H5Sall.c index 3b77b98..76181d1 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -18,16 +18,36 @@ * Purpose: "All" selection dataspace I/O functions. */ +/****************/ +/* Module Setup */ +/****************/ + #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 "H5VMprivate.h" /* Vector functions */ + + +/****************/ +/* Local Macros */ +/****************/ + -/* Static function prototypes */ +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ /* Selection callbacks */ static herr_t H5S__all_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); @@ -60,6 +80,16 @@ 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_release(H5S_sel_iter_t *sel_iter); + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + /* Selection properties for "all" selections */ const H5S_select_class_t H5S_sel_all[1] = {{ H5S_SEL_ALL, @@ -85,6 +115,11 @@ const H5S_select_class_t H5S_sel_all[1] = {{ H5S__all_iter_init, }}; + +/*******************/ +/* Local Variables */ +/*******************/ + /* Iteration properties for "all" selections */ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ H5S_SEL_ALL, @@ -99,13 +134,14 @@ static const H5S_sel_iter_class_t H5S_sel_iter_all[1] = {{ H5S__all_iter_release, }}; + /*------------------------------------------------------------------------- * Function: H5S__all_iter_init * * Purpose: Initializes iteration information for "all" selection. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 @@ -132,7 +168,7 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) iter->type = H5S_sel_iter_all; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_iter_init() */ +} /* end H5S__all_iter_init() */ /*------------------------------------------------------------------------- @@ -141,7 +177,7 @@ H5S__all_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 @@ -165,7 +201,7 @@ H5S__all_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__all_iter_coords() */ +} /* end H5S__all_iter_coords() */ /*------------------------------------------------------------------------- @@ -174,7 +210,7 @@ done: * Purpose: Retrieve the current block of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 @@ -204,7 +240,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_iter_block() */ +} /* end H5S__all_iter_block() */ /*------------------------------------------------------------------------- @@ -212,7 +248,7 @@ H5S__all_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) * * Purpose: Return number of elements left to process in iterator * - * Return: non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 @@ -228,7 +264,7 @@ H5S__all_iter_nelmts(const H5S_sel_iter_t *iter) HDassert(iter); FUNC_LEAVE_NOAPI(iter->elmt_left) -} /* H5S__all_iter_nelmts() */ +} /* end H5S__all_iter_nelmts() */ /*-------------------------------------------------------------------------- @@ -257,7 +293,7 @@ H5S__all_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) HDassert(iter); FUNC_LEAVE_NOAPI(FALSE) -} /* H5S__all_iter_has_next_block() */ +} /* end H5S__all_iter_has_next_block() */ /*-------------------------------------------------------------------------- @@ -292,7 +328,7 @@ H5S__all_iter_next(H5S_sel_iter_t *iter, size_t nelem) iter->u.all.byte_offset += (nelem * iter->elmt_size); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_iter_next() */ +} /* end H5S__all_iter_next() */ /*-------------------------------------------------------------------------- @@ -321,7 +357,7 @@ H5S__all_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) HDassert(iter); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S__all_iter_next_block() */ +} /* end H5S__all_iter_next_block() */ /*-------------------------------------------------------------------------- @@ -350,7 +386,7 @@ H5S__all_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) HDassert(iter); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_iter_release() */ +} /* end H5S__all_iter_release() */ /*-------------------------------------------------------------------------- @@ -382,7 +418,7 @@ H5S__all_release(H5S_t *space) space->select.num_elem = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_release() */ +} /* end H5S__all_release() */ /*-------------------------------------------------------------------------- @@ -391,9 +427,10 @@ H5S__all_release(H5S_t *space) PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S__all_copy(dst, src) + herr_t H5S__all_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -527,7 +564,7 @@ H5S__all_serialize(const H5S_t *space, uint8_t **p) *p = pp; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_serialize() */ +} /* end H5S__all_serialize() */ /*-------------------------------------------------------------------------- @@ -572,7 +609,7 @@ H5S__all_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_A done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__all_deserialize() */ +} /* end H5S__all_deserialize() */ /*-------------------------------------------------------------------------- @@ -622,7 +659,7 @@ H5S__all_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) } /* end for */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_bounds() */ +} /* end H5S__all_bounds() */ /*-------------------------------------------------------------------------- @@ -657,7 +694,7 @@ H5S__all_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) *offset = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_offset() */ +} /* end H5S__all_offset() */ /*-------------------------------------------------------------------------- @@ -716,7 +753,7 @@ H5S__all_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) HDassert(space); FUNC_LEAVE_NOAPI(TRUE) -} /* H5S__all_is_contiguous() */ +} /* end H5S__all_is_contiguous() */ /*-------------------------------------------------------------------------- @@ -745,7 +782,7 @@ H5S__all_is_single(const H5S_t H5_ATTR_UNUSED *space) HDassert(space); FUNC_LEAVE_NOAPI(TRUE) -} /* H5S__all_is_single() */ +} /* end H5S__all_is_single() */ /*-------------------------------------------------------------------------- @@ -776,7 +813,7 @@ H5S__all_is_regular(const H5S_t H5_ATTR_UNUSED *space) HDassert(space); FUNC_LEAVE_NOAPI(TRUE) -} /* H5S__all_is_regular() */ +} /* end H5S__all_is_regular() */ /*-------------------------------------------------------------------------- @@ -807,7 +844,7 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off HDassert(offset); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_adjust_u() */ +} /* end H5S__all_adjust_u() */ /*------------------------------------------------------------------------- @@ -816,7 +853,7 @@ H5S__all_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off * Purpose: Projects a single element 'all' selection into a scalar * dataspace * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -836,7 +873,7 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) *offset = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S__all_project_scalar() */ +} /* end H5S__all_project_scalar() */ /*------------------------------------------------------------------------- @@ -845,7 +882,7 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) * Purpose: Projects an 'all' selection onto/into a simple dataspace * of a different rank * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -853,7 +890,8 @@ H5S__all_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t *offset) *------------------------------------------------------------------------- */ static herr_t -H5S__all_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *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 */ @@ -870,7 +908,7 @@ H5S__all_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offs done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S__all_project_simple() */ +} /* end H5S__all_project_simple() */ /*-------------------------------------------------------------------------- @@ -914,7 +952,7 @@ H5S_select_all(H5S_t *space, hbool_t rel_prev) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_all() */ +} /* end H5S_select_all() */ /*-------------------------------------------------------------------------- @@ -953,7 +991,7 @@ H5Sselect_all(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sselect_all() */ +} /* end H5Sselect_all() */ /*-------------------------------------------------------------------------- diff --git a/src/H5Sdbg.c b/src/H5Sdbg.c index ebd05ce..b13e921 100644 --- a/src/H5Sdbg.c +++ b/src/H5Sdbg.c @@ -57,16 +57,16 @@ /********************/ -/*********************/ -/* Package Variables */ -/*********************/ - - /*****************************/ /* Library Private Variables */ /*****************************/ +/*********************/ +/* Package Variables */ +/*********************/ + + /*******************/ /* Local Variables */ /*******************/ diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 88c570d..e9354ca 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -18,21 +18,37 @@ * Purpose: Hyperslab selection dataspace I/O functions. */ +/****************/ +/* Module Setup */ +/****************/ + #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 "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +#include "H5VMprivate.h" /* Vector functions */ + +/****************/ /* Local Macros */ +/****************/ + -/* Local datatypes */ +/******************/ +/* Local Typedefs */ +/******************/ -/* Static function prototypes */ + +/********************/ +/* 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 herr_t H5S__hyper_span_precompute(H5S_hyper_span_info_t *spans, size_t elmt_size); @@ -64,7 +80,6 @@ static herr_t H5S__hyper_generate_spans(H5S_t *space); 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[]); -/* Needed for use in hyperslab code (H5Shyper.c) */ #ifdef NEW_HYPERSLAB_API static herr_t H5S_select_select (H5S_t *space1, H5S_seloper_t op, H5S_t *space2); #endif /*NEW_HYPERSLAB_API*/ @@ -111,6 +126,15 @@ static hbool_t H5S__hyper_rebuild_helper(const H5S_hyper_span_t *span, H5S_hyper_dim_t span_slab_info[], unsigned rank); static hbool_t H5S__hyper_rebuild(H5S_t *space); +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + /* Selection properties for hyperslab selections */ const H5S_select_class_t H5S_sel_hyper[1] = {{ H5S_SEL_HYPERSLABS, @@ -136,6 +160,11 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{ H5S__hyper_iter_init, }}; + +/*******************/ +/* Local Variables */ +/*******************/ + /* Iteration properties for hyperslab selections */ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ H5S_SEL_HYPERSLABS, @@ -153,16 +182,16 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ /* Static variables */ /* Arrays for default stride, block, etc. */ -static const hsize_t H5S_hyper_zeros_g[H5O_LAYOUT_NDIMS] = { +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,0}; -static const hsize_t H5S_hyper_ones_g[H5O_LAYOUT_NDIMS] = { + 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,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); @@ -261,9 +290,9 @@ H5S__hyper_print_diminfo(FILE *f, const H5S_t *space) /*------------------------------------------------------------------------- * Function: H5S__hyper_iter_init * - * Purpose: Initializes iteration information for hyperslab span tree selection. + * Purpose: Initializes iteration information for hyperslab selection. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Saturday, February 24, 2001 @@ -334,7 +363,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) /* Check if the regular selection can be "flattened" */ if(cont_dim > 0) { hsize_t acc; /* Accumulator for "flattened" dimension's sizes */ - unsigned last_dim_flattened = 1; /* Flag to indicate that the last dimension was flattened */ + 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 */ int i; /* Index variable */ @@ -351,7 +380,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) acc *= mem_size[i]; /* Indicate that the dimension was flattened */ - last_dim_flattened = 1; + last_dim_flattened = TRUE; } /* end if */ else { if(last_dim_flattened) { @@ -369,7 +398,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) iter->u.hyp.sel_off[curr_dim] = space->select.offset[i] * (hssize_t)acc; /* Reset the "last dim flattened" flag to avoid flattened any further dimensions */ - last_dim_flattened = 0; + last_dim_flattened = FALSE; /* Reset the "accumulator" for possible further dimension flattening */ acc = 1; @@ -414,10 +443,9 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) /* Initialize irregular region information also (for release) */ iter->u.hyp.spans = NULL; } /* end if */ - else { + else { /* Initialize the information needed for non-regular hyperslab I/O */ H5S_hyper_span_info_t *spans; /* Pointer to hyperslab span info node */ -/* Initialize the information needed for non-regular hyperslab I/O */ HDassert(space->select.sel_info.hslab->span_lst); /* Make a copy of the span tree to iterate over */ iter->u.hyp.spans = H5S__hyper_copy_span(space->select.sel_info.hslab->span_lst); @@ -459,7 +487,7 @@ H5S__hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 @@ -544,7 +572,7 @@ H5S__hyper_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) * Purpose: Retrieve the current block of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 @@ -570,7 +598,7 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) /* Check for a single "regular" hyperslab */ if(iter->u.hyp.diminfo_valid) { - /* Compute the end of the block */ + /* Copy the start and compute the end of the block */ 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; @@ -595,7 +623,7 @@ H5S__hyper_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) * * Purpose: Return number of elements left to process in iterator * - * Return: non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 @@ -631,7 +659,7 @@ H5S__hyper_iter_nelmts(const H5S_sel_iter_t *iter) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static htri_t +static H5_ATTR_PURE htri_t H5S__hyper_iter_has_next_block(const H5S_sel_iter_t *iter) { unsigned u; /* Local index variable */ @@ -689,7 +717,7 @@ 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 i; /* Counters */ + unsigned u; /* Counters */ FUNC_ENTER_STATIC_NOERR @@ -697,19 +725,17 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* (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[H5O_LAYOUT_NDIMS]; - hsize_t iter_count[H5O_LAYOUT_NDIMS]; + 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; - } /* end if */ - else { + else /* Set the aliases for the dimension rank */ ndims = iter->rank; - } /* end else */ /* Set the fastest dimension rank */ fast_dim = (int)ndims - 1; @@ -718,14 +744,14 @@ 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(i = 0; i < ndims; i++) { - if(tdiminfo[i].count == 1) { - iter_offset[i] = iter->u.hyp.off[i] - tdiminfo[i].start; - iter_count[i] = 0; + 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; } /* end if */ else { - iter_offset[i] = (iter->u.hyp.off[i] - tdiminfo[i].start) % tdiminfo[i].stride; - iter_count[i] = (iter->u.hyp.off[i] - tdiminfo[i].start) / tdiminfo[i].stride; + 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; } /* end else */ } /* end for */ @@ -750,10 +776,9 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Decrement the number of elements advanced */ nelem -= actual_elem; } /* end if */ - else { + else /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; - } /* end else */ /* 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) @@ -776,8 +801,8 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) } /* end while */ /* Translate current iter_offset and iter_count into iterator position */ - for(i = 0; i < ndims; i++) - iter->u.hyp.off[i] = tdiminfo[i].start + (tdiminfo[i].stride * iter_count[i]) + iter_offset[i]; + 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 { @@ -821,15 +846,13 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) /* Decrement the number of elements advanced */ nelem -= actual_elem; } /* end if */ - else { + else /* Move to the next row in the current dimension */ abs_arr[curr_dim]++; - } /* end else */ /* 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; - } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ @@ -845,10 +868,9 @@ H5S__hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem) break; } /* end if */ - else { + else /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; - } /* end else */ } /* end else */ } /* end while */ @@ -907,22 +929,20 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) FUNC_ENTER_STATIC_NOERR /* Check for the special case of just one H5Sselect_hyperslab call made */ - /* (i.e. a regular hyperslab selection */ + /* (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[H5O_LAYOUT_NDIMS]; - hsize_t iter_count[H5O_LAYOUT_NDIMS]; + 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; - } /* end if */ - else { + else /* Set the aliases for the dimension rank */ ndims = iter->rank; - } /* end else */ /* Set the fastest dimension rank */ fast_dim = (int)ndims - 1; @@ -945,14 +965,12 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) /* Advance one block */ temp_dim = fast_dim; /* Start with the fastest changing dimension */ while(temp_dim >= 0) { - if(temp_dim == fast_dim) { + if(temp_dim == fast_dim) /* Move iterator over current block */ iter_offset[temp_dim] += tdiminfo[temp_dim].block; - } /* end if */ - else { + else /* Move to the next row in the current dimension */ iter_offset[temp_dim]++; - } /* end else */ /* 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) @@ -1001,19 +1019,16 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) 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; - } /* end if */ - else { + else /* Move to the next row in the current dimension */ abs_arr[curr_dim]++; - } /* end else */ /* 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; - } /* end if */ /* If we walked off that span, advance to the next span */ else { /* Advance span in this dimension */ @@ -1029,10 +1044,9 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) break; } /* end if */ - else { + else /* If we finished the span list in this dimension, decrement the dimension worked on and loop again */ curr_dim--; - } /* end else */ } /* end else */ } /* end while */ @@ -1063,7 +1077,7 @@ H5S__hyper_iter_next_block(H5S_sel_iter_t *iter) } /* end else */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S__hyper_iter_next() */ +} /* end H5S__hyper_iter_next_block() */ /*-------------------------------------------------------------------------- @@ -1404,6 +1418,7 @@ H5S__hyper_copy_span(H5S_hyper_span_info_t *spans) FUNC_ENTER_STATIC + /* Sanity check */ HDassert(spans); /* Copy the hyperslab span tree */ @@ -1422,23 +1437,24 @@ done: NAME H5S__hyper_cmp_spans PURPOSE - Check if two hyperslab slabs are the same + Check if two hyperslab span trees are the same USAGE hbool_t H5S__hyper_cmp_spans(span1, span2) - H5S_hyper_span_t *span1; IN: First span tree to compare - H5S_hyper_span_t *span2; IN: Second span tree to compare + H5S_hyper_span_info_t *span_info1; IN: First span tree to compare + H5S_hyper_span_info_t *span_info2; IN: Second span tree to compare RETURNS TRUE (1) or FALSE (0) on success, can't fail DESCRIPTION - Compare two hyperslab slabs to determine if they refer to the same - selection. If span1 & span2 are both NULL, that counts as equal + Compare two hyperslab span trees to determine if they refer to the same + selection. If span1 & span2 are both NULL, that counts as equal. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static hbool_t -H5S__hyper_cmp_spans(const H5S_hyper_span_info_t *span_info1, const H5S_hyper_span_info_t *span_info2) +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 = FALSE; /* Return value */ @@ -1610,9 +1626,10 @@ done: PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S__hyper_copy(dst, src) + herr_t H5S__hyper_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -2045,7 +2062,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, HDassert(spans); HDassert(start); HDassert(end); - HDassert(rank < H5O_LAYOUT_NDIMS); + HDassert(rank < H5S_MAX_RANK); HDassert(p && pp); /* Walk through the list of spans, recursing or outputting them */ @@ -2088,7 +2105,7 @@ H5S__hyper_serialize_helper(const H5S_hyper_span_info_t *spans, *p = pp; FUNC_LEAVE_NOAPI_VOID -} /* H5S__hyper_serialize_helper() */ +} /* end H5S__hyper_serialize_helper() */ /*-------------------------------------------------------------------------- @@ -2170,8 +2187,8 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) /* Check for a "regular" hyperslab selection */ else if(space->select.sel_info.hslab->diminfo_valid) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */ + hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ unsigned fast_dim; /* Rank of the fastest changing dimension for the dataspace */ unsigned ndims; /* Rank of the dataspace */ unsigned u; /* Local counting variable */ @@ -2261,8 +2278,8 @@ H5S__hyper_serialize(const H5S_t *space, uint8_t **p) } /* end while */ } /* end if */ else { - hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* 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 */ /* Encode number of hyperslabs */ block_count = H5S__hyper_span_nblocks(space->select.sel_info.hslab->span_lst); @@ -2318,8 +2335,8 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl { unsigned rank; /* Rank of points */ const uint8_t *pp; /* Local pointer for decoding */ - hsize_t start[H5O_LAYOUT_NDIMS]; /* Hyperslab start information */ - hsize_t block[H5O_LAYOUT_NDIMS]; /* Hyperslab block information */ + hsize_t start[H5S_MAX_RANK]; /* Hyperslab start information */ + hsize_t block[H5S_MAX_RANK]; /* Hyperslab block information */ unsigned u; /* Local counting variable */ herr_t ret_value = FAIL; /* Return value */ @@ -2337,8 +2354,8 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl /* If there is an unlimited dimension, only encode opt_unlim_diminfo */ if(flags & H5S_SELECT_FLAG_UNLIM) { - hsize_t stride[H5O_LAYOUT_NDIMS]; /* Hyperslab stride information */ - hsize_t count[H5O_LAYOUT_NDIMS]; /* Hyperslab count information */ + 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); @@ -2360,7 +2377,7 @@ H5S__hyper_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t fl else { const hsize_t *stride; /* Hyperslab stride information */ const hsize_t *count; /* Hyperslab count information */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* Hyperslab end 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 */ @@ -2447,7 +2464,7 @@ H5S__hyper_span_blocklist(const H5S_hyper_span_info_t *spans, hsize_t start[], /* Sanity checks */ HDassert(spans); - HDassert(rank < H5O_LAYOUT_NDIMS); + HDassert(rank < H5S_MAX_RANK); HDassert(start); HDassert(end); HDassert(startblock); @@ -2551,8 +2568,8 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo /* Check for a "regular" hyperslab selection */ if(space->select.sel_info.hslab->diminfo_valid) { const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary hyperslab counts */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Offset of element in dataspace */ + hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */ + hsize_t offset[H5S_MAX_RANK]; /* Offset of element 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 */ @@ -2662,8 +2679,8 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo } /* end while */ } /* end if */ else { - hsize_t start[H5O_LAYOUT_NDIMS]; /* Location of start of hyperslab */ - hsize_t end[H5O_LAYOUT_NDIMS]; /* 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); } /* end else */ @@ -2771,7 +2788,7 @@ H5S_hyper_bounds_helper(const H5S_hyper_span_info_t *spans, const hssize_t *offs HDassert(spans); HDassert(offset); - HDassert(rank < H5O_LAYOUT_NDIMS); + HDassert(rank < H5S_MAX_RANK); HDassert(start); HDassert(end); @@ -3075,7 +3092,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static htri_t +static H5_ATTR_PURE htri_t H5S__hyper_is_contiguous(const H5S_t *space) { hbool_t small_contiguous, /* Flag for small contiguous block */ @@ -3145,10 +3162,10 @@ H5S__hyper_is_contiguous(const H5S_t *space) /* * For a hyperslab to be contiguous, it must have only one block and - * (either it's size must be the same as the dataspace extent's in all - * but the slowest changing dimension - * OR - * block size must be 1 in all but the fastest changing dimension). + * either it's size must be the same as the dataspace extent's in all + * but the slowest changing dimension + * OR + * 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 */ @@ -3260,7 +3277,7 @@ H5S__hyper_is_contiguous(const H5S_t *space) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static htri_t +static H5_ATTR_PURE htri_t H5S__hyper_is_single(const H5S_t *space) { htri_t ret_value = TRUE; /* return value */ @@ -4242,7 +4259,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset) * Purpose: Projects a single element hyperslab selection into a scalar * dataspace * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -4305,7 +4322,7 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset) * Purpose: Projects a hyperslab selection onto/into a simple dataspace * of a lower rank * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -4352,7 +4369,7 @@ H5S__hyper_project_simple_lower(const H5S_t *base_space, H5S_t *new_space) * Purpose: Projects a hyperslab selection onto/into a simple dataspace * of a higher rank * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -4442,7 +4459,7 @@ done: * Purpose: Projects a hyperslab selection onto/into a simple dataspace * of a different rank * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -4450,7 +4467,8 @@ done: *------------------------------------------------------------------------- */ 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 */ @@ -4939,9 +4957,10 @@ done: DESCRIPTION Clip one span tree ('a') against another span tree ('b'). Creates span trees for the area defined by the 'a' span tree which does not overlap the - 'b' span tree, the area defined by the overlap of the 'a' hyperslab span - tree and the 'b' span tree, and the area defined by the 'b' hyperslab span - tree which does not overlap the 'a' span tree. + 'b' span tree ("a not b"), the area defined by the overlap of the 'a' + hyperslab span tree and the 'b' span tree ("a and b"), and the area defined + by the 'b' hyperslab span tree which does not overlap the 'a' span + tree ("b not a"). GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -5850,12 +5869,12 @@ H5S__hyper_spans_nelem(const H5S_hyper_span_info_t *spans) Create a span tree USAGE H5S_hyper_span_t *H5S__hyper_make_spans(rank, start, stride, count, block) - unsigned rank; IN: # of dimensions of the space - const hsize_t *start; IN: Starting location of the hyperslabs - const hsize_t *stride; IN: Stride from the beginning of one block to + unsigned rank; IN: # of dimensions of the space + const hsize_t *start; IN: Starting location of the hyperslabs + const hsize_t *stride; IN: Stride from the beginning of one block to the next - const hsize_t *count; IN: Number of blocks - const hsize_t *block; IN: Size of hyperslab block + const hsize_t *count; IN: Number of blocks + const hsize_t *block; IN: Size of hyperslab block RETURNS Pointer to new span tree on success, NULL on failure DESCRIPTION @@ -6139,7 +6158,7 @@ done: static hbool_t H5S__hyper_rebuild(H5S_t *space) { - H5S_hyper_dim_t top_span_slab_info[H5O_LAYOUT_NDIMS]; + H5S_hyper_dim_t top_span_slab_info[H5S_MAX_RANK]; unsigned rank, curr_dim; hbool_t ret_value = TRUE; /* Return value */ @@ -6201,12 +6220,12 @@ done: static herr_t H5S__hyper_generate_spans(H5S_t *space) { - hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ - hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ - hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* 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 @@ -6247,19 +6266,14 @@ done: * * Return: Non-negative on success/Negative on failure * - * Programmer: Quincey Koziol (split from HS_select_hyperslab()). + * Programmer: Quincey Koziol * Tuesday, September 12, 2000 * - * Modifications: - * *------------------------------------------------------------------------- */ 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 */ H5S_hyper_span_info_t *a_not_b = NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ @@ -6291,7 +6305,7 @@ H5S__generate_hyperslab (H5S_t *space, H5S_seloper_t op, space->select.num_elem = H5S__hyper_spans_nelem(new_spans); /* Indicate that the new_spans are owned */ - new_spans=NULL; + new_spans = NULL; } /* end if */ else { hbool_t updated_spans = FALSE; /* Whether the spans in the selection were modified */ @@ -6500,9 +6514,9 @@ 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) { - hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */ - hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */ - hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */ + 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 */ @@ -6526,9 +6540,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], if(block == NULL) block = H5S_hyper_ones_g; - /* - * Check new selection. - */ + /* Check new selection */ for(u = 0; u < space->extent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ if(count[u] > 1 && stride[u] < block[u]) @@ -6564,7 +6576,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], 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] /* == H5S_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 */ @@ -6793,7 +6805,8 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[], HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds") /* Patch count and block to remove unlimited and include the - * existing selection */ + * 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); HDassert((tmp_count == 1) || (opt_count != H5S_hyper_ones_g)); HDassert((tmp_block == 1) || (opt_block != H5S_hyper_ones_g)); @@ -7193,9 +7206,9 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t count[], const hsize_t *block) { - hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */ - hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */ - hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */ + 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 */ @@ -7212,11 +7225,11 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, 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 for unlimited dimension */ @@ -7236,7 +7249,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, */ for(u=0; uextent.rank; u++) { /* Check for overlapping hyperslab blocks in new selection. */ - if(count[u]>1 && stride[u] 1 && stride[u] < block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap") /* Detect zero-sized hyperslabs in new selection */ @@ -7364,10 +7377,10 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, /* Convert current "all" selection to "real" hyperslab selection */ /* Then allow operation to proceed */ { - hsize_t tmp_start[H5O_LAYOUT_NDIMS]; /* Temporary start information */ - hsize_t tmp_stride[H5O_LAYOUT_NDIMS]; /* Temporary stride information */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS]; /* Temporary count information */ - hsize_t tmp_block[H5O_LAYOUT_NDIMS]; /* Temporary block information */ + 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 */ /* Fill in temporary information for the dimensions */ for(u=0; uextent.rank; u++) { @@ -7657,9 +7670,6 @@ done: * Programmer: Quincey Koziol * Tuesday, October 30, 2001 * - * Chao Mei - * Wednesday, June 29, 2011 - * *------------------------------------------------------------------------- */ static H5S_t * @@ -7789,8 +7799,6 @@ done: * Programmer: Quincey Koziol * Tuesday, October 30, 2001 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t @@ -7892,7 +7900,7 @@ H5Sselect_select(hid_t space1_id, H5S_seloper_t op, hid_t space2_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspaces don't have hyperslab selections") /* Go refine the first selection */ - if (H5S_select_select(space1, op, space2)<0) + if(H5S_select_select(space1, op, space2) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to modify hyperslab selection") done: @@ -7938,7 +7946,7 @@ H5S__hyper_get_seq_list_gen(const H5S_t *space, H5S_sel_iter_t *iter, { H5S_hyper_span_t *curr_span; /* Current hyperslab span node */ H5S_hyper_span_t **ispan; /* Iterator's hyperslab span nodes */ - hsize_t slab[H5O_LAYOUT_NDIMS]; /* Cumulative size of each dimension in bytes */ + hsize_t slab[H5S_MAX_RANK]; /* Cumulative size of each dimension in bytes */ hsize_t acc; /* Accumulator for computing cumulative sizes */ hsize_t loc_off; /* Element offset in the dataspace */ hsize_t last_span_end = 0; /* The offset of the end of the last span */ @@ -8358,13 +8366,13 @@ H5S__hyper_get_seq_list_opt(const H5S_t *space, H5S_sel_iter_t *iter, hsize_t *off, size_t *len) { hsize_t *mem_size; /* Size of the source buffer */ - hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ + hsize_t slab[H5S_MAX_RANK]; /* Hyperslab size */ const hssize_t *sel_off; /* Selection offset in dataspace */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */ - hsize_t tmp_count[H5O_LAYOUT_NDIMS];/* Temporary block count */ - hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */ - hsize_t wrap[H5O_LAYOUT_NDIMS]; /* Bytes to wrap around at the end of a row */ - hsize_t skip[H5O_LAYOUT_NDIMS]; /* Bytes to skip between blocks */ + 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, @@ -8807,9 +8815,9 @@ H5S__hyper_get_seq_list_single(const H5S_t *space, H5S_sel_iter_t *iter, 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[H5O_LAYOUT_NDIMS]; /* Base coordinate offset in dataspace */ - hsize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */ - hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ + 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[H5S_MAX_RANK]; /* Hyperslab size */ hsize_t fast_dim_block; /* Local copies of fastest changing dimension info */ hsize_t acc; /* Accumulator */ hsize_t loc; /* Coordinate offset */ @@ -8949,8 +8957,8 @@ H5S__hyper_get_seq_list_single(const H5S_t *space, H5S_sel_iter_t *iter, offset[skip_dim] += tot_blk_count; } /* end if */ else { - hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */ - hsize_t skip[H5O_LAYOUT_NDIMS]; /* Bytes to skip between blocks */ + 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 */ @@ -9144,7 +9152,7 @@ H5S__hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_s /* 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[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ + hsize_t slab[H5S_MAX_RANK]; /* Hyperslab size */ hsize_t loc; /* Coordinate offset */ hsize_t acc; /* Accumulator */ size_t leftover; /* The number of elements left over from the last sequence */ @@ -9249,11 +9257,10 @@ H5S__hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_s 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 - 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 selection. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -9312,7 +9319,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, HDassert(dst_space); HDassert(src_intersect_space); HDassert(proj_space); - + /* Assert that src_space and src_intersect_space have same extent and there * are no point selections */ HDassert(H5S_GET_EXTENT_NDIMS(src_space) == H5S_GET_EXTENT_NDIMS(src_intersect_space)); @@ -9475,7 +9482,7 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, * selection and advance any sequences we complete */ if(ss_off[ss_i] >= sis_off[sis_i]) int_sel_off = ss_sel_off; - else + else int_sel_off = sis_off[sis_i] - ss_off[ss_i] + ss_sel_off; if((ss_off[ss_i] + (hsize_t)ss_len[ss_i]) <= (sis_off[sis_i] + (hsize_t)sis_len[sis_i])) { @@ -9599,8 +9606,9 @@ loop_end: /* 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); - /* Attempt to rebuild "optimized" start/stride/count/block information. - * from resulting hyperslab span tree */ + /* Attempt to build "optimized" start/stride/count/block information + * from resulting hyperslab span tree. + */ H5S__hyper_rebuild(proj_space); } /* end if */ else @@ -9841,7 +9849,7 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size) hsize_t orig_count; /* Original count in unlimited dimension */ int orig_unlim_dim; /* Original unliminted dimension */ H5S_hyper_dim_t *diminfo; /* Convenience pointer to opt_diminfo in unlimited dimension */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -10225,7 +10233,7 @@ H5S_hyper_get_unlim_block(const H5S_t *space, hsize_t block_index) /* Create output space, copy extent */ 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 */ @@ -10352,7 +10360,7 @@ H5Sis_regular_hyperslab(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sis_regular_hyperslab() */ +} /* end H5Sis_regular_hyperslab() */ /*-------------------------------------------------------------------------- @@ -10416,5 +10424,5 @@ H5Sget_regular_hyperslab(hid_t spaceid, hsize_t start[], hsize_t stride[], done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_regular_hyperslab() */ +} /* end H5Sget_regular_hyperslab() */ diff --git a/src/H5Smpio.c b/src/H5Smpio.c index 935d279..2ebe987 100644 --- a/src/H5Smpio.c +++ b/src/H5Smpio.c @@ -14,15 +14,20 @@ /* * Programmer: rky 980813 * - * Purpose: Functions to read/write directly between app buffer and file. + * Purpose: Create MPI data types for HDF5 selections. * - * Beware of the ifdef'ed print statements. - * I didn't make them portable. */ +/****************/ +/* Module Setup */ +/****************/ + #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 */ @@ -37,37 +42,61 @@ #ifdef H5_HAVE_PARALLEL -static herr_t H5S_mpio_all_type(const H5S_t *space, size_t elmt_size, +/****************/ +/* Local Macros */ +/****************/ +#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 +#define TWO_GIG_LIMIT 2147483648 +#ifndef H5S_MAX_MPI_COUNT +#define H5S_MAX_MPI_COUNT 536870911 /* (2^29)-1 */ +#endif + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* 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, +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, +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, +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, +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_hyper_type(const H5S_t *space, size_t elmt_size, +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, +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_obtain_datatype(const hsize_t down[], H5S_hyper_span_t* span, +static herr_t H5S__obtain_datatype(const hsize_t down[], H5S_hyper_span_t* span, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size); -static herr_t H5S_mpio_create_large_type (hsize_t, MPI_Aint, MPI_Datatype , MPI_Datatype *); +static herr_t H5S__mpio_create_large_type(hsize_t, MPI_Aint, MPI_Datatype , MPI_Datatype *); -#define H5S_MPIO_INITIAL_ALLOC_COUNT 256 +/*****************************/ +/* Library Private Variables */ +/*****************************/ -#define TWO_GIG_LIMIT 2147483648 -#ifndef H5S_MAX_MPI_COUNT -#define H5S_MAX_MPI_COUNT 536870911 /* (2^29)-1 */ -#endif +/*********************/ +/* Package Variables */ +/*********************/ + +/*******************/ +/* Local Variables */ +/*******************/ static hsize_t bigio_count = H5S_MAX_MPI_COUNT; + /*------------------------------------------------------------------------- * Function: H5S_mpio_set_bigio_count * @@ -75,7 +104,7 @@ static hsize_t bigio_count = H5S_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. * * Programmer: Richard Warren, March 10, 2017 * @@ -85,19 +114,20 @@ hsize_t H5S_mpio_set_bigio_count(hsize_t new_count) { hsize_t orig_count = bigio_count; - if ((new_count > 0) && (new_count < TWO_GIG_LIMIT)) { + + if((new_count > 0) && (new_count < TWO_GIG_LIMIT)) bigio_count = new_count; - } + return orig_count; -} +} /* end H5S_mpio_set_bigio_count() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_all_type + * Function: H5S__mpio_all_type * * Purpose: Translate an HDF5 "all" selection into an MPI type. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -105,16 +135,11 @@ H5S_mpio_set_bigio_count(hsize_t new_count) * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 - * Modifications: - * Mohamad Chaarawi - * Adding support for large datatypes (beyond the limit of a - * 32 bit integer. - * * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_all_type(const H5S_t *space, size_t elmt_size, +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; @@ -122,7 +147,7 @@ H5S_mpio_all_type(const H5S_t *space, size_t elmt_size, hsize_t nelmts; /* Total number of elmts */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -133,34 +158,33 @@ H5S_mpio_all_type(const H5S_t *space, size_t elmt_size, H5_CHECKED_ASSIGN(nelmts, hsize_t, snelmts, hssize_t); total_bytes = (hsize_t)elmt_size * nelmts; + /* Verify that the size can be expressed as a 32 bit integer */ if(bigio_count >= total_bytes) { - /* fill in the return values */ - *new_type = MPI_BYTE; - H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t); - *is_derived_type = FALSE; - } + /* fill in the return values */ + *new_type = MPI_BYTE; + H5_CHECKED_ASSIGN(*count, int, total_bytes, hsize_t); + *is_derived_type = FALSE; + } /* end if */ else { - /* Create a LARGE derived datatype for this transfer */ - if (H5S_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; - } + /* Create a LARGE derived datatype for this transfer */ + if(H5S__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; + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_mpio_all_type() */ +} /* H5S__mpio_all_type() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_none_type + * Function: H5S__mpio_none_type * * Purpose: Translate an HDF5 "none" selection into an MPI type. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -172,9 +196,9 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) +H5S__mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* fill in the return values */ *new_type = MPI_BYTE; @@ -182,15 +206,15 @@ H5S_mpio_none_type(MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) *is_derived_type = FALSE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_mpio_none_type() */ +} /* H5S__mpio_none_type() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_create_point_datatype + * Function: H5S__mpio_create_point_datatype * * Purpose: Create a derived datatype for point selections. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * @@ -198,18 +222,23 @@ 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_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 mpi_code; /* MPI error code */ + 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 */ +#endif + int mpi_code; /* MPI error code */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + 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))) @@ -219,146 +248,127 @@ H5S_mpio_create_point_datatype (size_t elmt_size, hsize_t num_points, /* Check whether standard or BIGIO processing will be employeed */ 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))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_indexed_block failed", mpi_code) + /* 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))) + 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))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") + /* Allocate block sizes for MPI datatype call */ + 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++) - blocks[u] = 1; + 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))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) + /* 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))) + 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))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) - } - else { - /* use LARGE_DATATYPE:: - * 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; - hsize_t leftover; - - int *inner_blocks; - MPI_Aint *inner_disps; - MPI_Datatype *inner_types = NULL; + /* Commit MPI datatype for later use */ + if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(new_type))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) + } /* end if */ + else { + /* use LARGE_DATATYPE:: + * 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; + hsize_t leftover; - /* Calculate how many Big MPI datatypes are needed to represent the buffer */ - num_big_types = (int)(num_points/bigio_count); + /* Calculate how many Big MPI datatypes are needed to represent the buffer */ + num_big_types = (int)(num_points / bigio_count); - leftover = (hsize_t)num_points - (hsize_t)num_big_types * (hsize_t)bigio_count; - H5_CHECKED_ASSIGN(remaining_points, int, leftover, hsize_t); + leftover = (hsize_t)num_points - (hsize_t)num_big_types * (hsize_t)bigio_count; + H5_CHECKED_ASSIGN(remaining_points, int, leftover, hsize_t); - total_types = (int)(remaining_points) ? (num_big_types + 1) : num_big_types; + 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)))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") + /* Allocate array if MPI derived types needed */ + 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))) - 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))) + 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))) - 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))) + 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))) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate array of blocks") + /* Allocate block sizes for MPI datatype call */ + 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++) - blocks[u] = 1; + for(u = 0; u < bigio_count; u++) + blocks[u] = 1; #endif - for(i=0 ; i= 3 - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count, - 1, - &disp[i*bigio_count], - elmt_type, - &inner_types[i]))) { - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); - } + if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(bigio_count, + 1, &disp[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]))) { - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - } + 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; - } + 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[num_big_types*bigio_count], - elmt_type, - &inner_types[num_big_types]))) { - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed_block failed", mpi_code); - } + if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed_block(remaining_points, + 1, &disp[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]))) { - HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) - } + 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; - } - - 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 ; iselect.sel_info.pnt_lst->head; for(u = 0 ; u < num_points ; u++) { - /* calculate the displacement of the current point */ + /* Calculate the displacement of the current point */ disp[u] = H5VM_array_offset(space->extent.rank, space->extent.size, curr->pnt); disp[u] *= elmt_size; - /* This is a File Space used to set the file view, so adjust the displacements + /* This is a File Space used to set the file view, so adjust the displacements * to have them monotonically non-decreasing. - * Generate the permutation array by indicating at each point being selected, - * the position it will shifted in the new displacement. Example: - * Suppose 4 points with corresponding are selected - * Pt 1: disp=6 ; Pt 2: disp=3 ; Pt 3: disp=0 ; Pt 4: disp=4 + * Generate the permutation array by indicating at each point being selected, + * the position it will shifted in the new displacement. Example: + * Suppose 4 points with corresponding are selected + * Pt 1: disp=6 ; Pt 2: disp=3 ; Pt 3: disp=0 ; Pt 4: disp=4 * The permute map to sort the displacements in order will be: * point 1: map[0] = L, indicating that this point is not moved (1st point selected) - * point 2: map[1] = 0, indicating that this point is moved to the first position, + * point 2: map[1] = 0, indicating that this point is moved to the first position, * since disp_pt1(6) > disp_pt2(3) - * point 3: map[2] = 0, move to position 0, bec it has the lowest disp between + * point 3: map[2] = 0, move to position 0, bec it has the lowest disp between * the points selected so far. - * point 4: map[3] = 2, move the 2nd position since point 1 has a higher disp, + * 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) { @@ -447,7 +457,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type HDmemmove(disp + m + 1, disp + m, (u - m) * sizeof(MPI_Aint)); disp[m] = temp; } /* end if */ - (*permute)[u] = m; + (*permute)[u] = m; } /* end if */ else (*permute)[u] = num_points; @@ -455,7 +465,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type /* this is a memory space, and no permutation is necessary to create the derived datatype */ else { - ;/* do nothing */ + ; /* do nothing */ } /* end else */ /* get the next point */ @@ -463,7 +473,7 @@ H5S_mpio_point_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type } /* 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 */ @@ -481,11 +491,11 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_mpio_point_type() */ +} /* H5S__mpio_point_type() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_permute_type + * Function: H5S__mpio_permute_type * * Purpose: Translate an HDF5 "all/hyper/point" selection into an MPI type, * while applying the permutation map. This function is called if @@ -496,7 +506,7 @@ done: * Note: This routine is called from H5S_mpio_space_type(), which is * called first for the file dataspace and creates * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -508,7 +518,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, +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*/ @@ -520,7 +530,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, hsize_t u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -571,12 +581,12 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, /* Set the displacement of the current point */ disp[u] = curr_off; - /* This is a memory displacement, so for each point selected, + /* 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) { MPI_Aint temp = disp[u]; - HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u], + HDmemmove(disp + (*permute)[u] + 1, disp + (*permute)[u], (u - (*permute)[u]) * sizeof(MPI_Aint)); disp[(*permute)[u]] = temp; } /* end if */ @@ -597,7 +607,7 @@ H5S_mpio_permute_type(const H5S_t *space, size_t elmt_size, hsize_t **permute, } /* 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 */ @@ -619,15 +629,15 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_mpio_permute_type() */ +} /* H5S__mpio_permute_type() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_hyper_type + * Function: H5S__mpio_reg_hyper_type * - * Purpose: Translate an HDF5 hyperslab selection into an MPI type. + * Purpose: Translate a regular HDF5 hyperslab selection into an MPI type. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -635,14 +645,11 @@ done: * *is_derived_type 0 if MPI primitive type, 1 if derived * * Programmer: rky 980813 - * Modifications: - * Mohamad Chaarawi - * Adding support for large datatypes (beyond the limit of a - * 32 bit integer. + * *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, +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 */ @@ -668,7 +675,7 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -683,16 +690,15 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, diminfo = sel_iter.u.hyp.diminfo; HDassert(diminfo); - /* make a local copy of the dimension info so we can operate with them */ + /* 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) { /* Flattened selection */ rank = sel_iter.u.hyp.iter_rank; - HDassert(rank <= H5S_MAX_RANK); /* within array bounds */ #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) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) @@ -701,33 +707,30 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, d[u].block = diminfo[u].block; d[u].count = diminfo[u].count; 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=%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"); +} #endif - if(0 == d[u].block) - goto empty; - if(0 == d[u].count) - goto empty; - if(0 == d[u].xtent) - goto empty; + + /* Sanity check */ + HDassert(d[u].block > 0); + HDassert(d[u].count > 0); + HDassert(d[u].xtent > 0); } /* end for */ } /* end if */ else { /* Non-flattened selection */ rank = space->extent.rank; - HDassert(rank <= H5S_MAX_RANK); /* within array bounds */ - if(0 == rank) - goto empty; #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) { H5_CHECK_OVERFLOW(diminfo[u].start, hsize_t, hssize_t) @@ -736,22 +739,22 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, d[u].block = diminfo[u].block; d[u].count = diminfo[u].count; d[u].xtent = space->extent.size[u]; + #ifdef H5S_DEBUG - if(H5DEBUG(S)){ +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 ); + 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" ); - } + HDfprintf(H5DEBUG(S), "\n"); +} #endif - if(0 == d[u].block) - goto empty; - if(0 == d[u].count) - goto empty; - if(0 == d[u].xtent) - goto empty; + + /* Sanity check */ + HDassert(d[u].block > 0); + HDassert(d[u].count > 0); + HDassert(d[u].xtent > 0); } /* end for */ } /* end else */ @@ -762,56 +765,52 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, 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]=%Hu; max_xtent[%2d]=%Hu\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; 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]=%Hu; max_xtent[%2d]=%Hu\n", i, offset[i], i, max_xtent[i]); #endif } /* end for */ /* Create a type covering the selected hyperslab. * Multidimensional dataspaces are stored in row-major order. * The type is built from the inside out, going from the - * fastest-changing (i.e., inner) dimension * to the slowest (outer). */ + * fastest-changing (i.e., inner) dimension * to the slowest (outer). + */ /******************************************************* * Construct contig type for inner contig dims: *******************************************************/ #ifdef H5S_DEBUG - if(H5DEBUG(S)) { +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); - } +} #endif /* LARGE_DATATYPE:: - * Check if the number of elements to form the inner type fits into a 32 bit integer. + * Check if the number of elements to form the inner type fits into a 32 bit integer. * If yes then just create the innertype with MPI_Type_contiguous. * Otherwise create a compound datatype by iterating as many times as needed * for the innertype to be created. */ 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))) - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - } - else { - /* Create the compound datatype for this operation (> 2GB) */ - if (H5S_mpio_create_large_type (elmt_size, 0, MPI_BYTE, &inner_type) < 0) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, - "couldn't ccreate a large inner datatype in hyper selection") - } - } + /* 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))) + HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) + } /* end if */ + else + /* Create the compound datatype for this operation (> 2GB) */ + if(H5S__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 @@ -819,65 +818,57 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, *******************************************************/ 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=%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]); #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) { - - /* 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_Type_free(&inner_type); - if(mpi_code != MPI_SUCCESS) - HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code) - } + * 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_Type_free(&inner_type); + if(mpi_code != MPI_SUCCESS) + HMPI_GOTO_ERROR(FAIL, "couldn't create MPI vector type", mpi_code) + } /* end if */ 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 - * 2) a collection of elements where an element is a contiguous block(1). - * Remember that the input arguments to the MPI-IO functions use integer - * values to represent element counts. We ARE allowed however, in the - * more recent MPI implementations to use constructed datatypes whereby - * the total number of bytes in a transfer could be : - * (2GB-1)number_of_blocks * the_datatype_extent. - */ + /* 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 + * 2) a collection of elements where an element is a contiguous block(1). + * Remember that the input arguments to the MPI-IO functions use integer + * values to represent element counts. We ARE allowed however, in the + * more recent MPI implementations to use constructed datatypes whereby + * the total number of bytes in a transfer could be : + * (2GB-1)number_of_blocks * the_datatype_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 + /* 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 (H5S_mpio_create_large_type(d[i].block, 0, inner_type, - &block_type) < 0) { - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, - "couldn't ccreate a large block datatype in hyper selection") - } - } - else { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous((int)d[i].block, - inner_type, - &block_type))) + if(bigio_count < d[i].block) { + if(H5S__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") + } /* end if */ + 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 @@ -892,40 +883,38 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, /* 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 (H5S_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(H5S__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") + } /* end if */ /* otherwise a regular create_hvector will do */ - else { - 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 */ - if(MPI_SUCCESS != 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); - } - /**************************************** - * Then build the dimension type as (start, vector type, xtent). - ****************************************/ - /* calculate start and extent values of this dimension */ + } /* end else */ + + /**************************************** + * Then build the dimension type as (start, vector type, xtent). + ****************************************/ + + /* Calculate start and extent values of this dimension */ start_disp = d[i].start * offset[i] * elmt_size; new_extent = (MPI_Aint)elmt_size * max_xtent[i]; 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) /************************************************* - * Restructure this datatype ("outer_type") - * so that it still starts at 0, but its extent - * is the full extent in this dimension. - *************************************************/ + * Restructure this datatype ("outer_type") + * 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) { MPI_Datatype interm_type; int block_len = 1; @@ -957,13 +946,6 @@ H5S_mpio_hyper_type(const H5S_t *space, size_t elmt_size, /* fill in the remaining return values */ *count = 1; /* only have to move one of these suckers! */ *is_derived_type = TRUE; - HGOTO_DONE(SUCCEED); - -empty: - /* special case: empty hyperslab */ - *new_type = MPI_BYTE; - *count = 0; - *is_derived_type = FALSE; done: /* Release selection iterator */ @@ -972,21 +954,20 @@ done: 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=%ld is_derived_type=%t\n", FUNC, *count, *is_derived_type); #endif FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_mpio_hyper_type() */ +} /* end H5S__mpio_reg_hyper_type() */ /*------------------------------------------------------------------------- - * Function: H5S_mpio_span_hyper_type + * Function: H5S__mpio_span_hyper_type * * Purpose: Translate an HDF5 irregular hyperslab selection into an MPI type. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -995,14 +976,10 @@ done: * * Programmer: kyang * - * Modifications: - * Mohamad Chaarawi - * Adding support for large datatypes (beyond the limit of a - * 32 bit integer. *------------------------------------------------------------------------- */ static herr_t -H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, +H5S__mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, int *count, hbool_t *is_derived_type) { MPI_Datatype elmt_type; /* MPI datatype for an element */ @@ -1012,7 +989,7 @@ H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, int mpi_code; /* MPI return code */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -1021,17 +998,13 @@ H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, HDassert(space->select.sel_info.hslab->span_lst->head); /* 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))) { - HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - } - } - else { - if (H5S_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") - } - } + 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) + } /* end if */ + else + if(H5S__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 */ @@ -1039,8 +1012,8 @@ H5S_mpio_span_hyper_type(const H5S_t *space, size_t elmt_size, HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGETSIZE, FAIL, "couldn't compute 'down' dimension sizes") /* Obtain derived data type */ - if(H5S_obtain_datatype(down, space->select.sel_info.hslab->span_lst->head, &elmt_type, &span_type, elmt_size) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") + if(H5S__obtain_datatype(down, space->select.sel_info.hslab->span_lst->head, &elmt_type, &span_type, elmt_size) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") if(MPI_SUCCESS != (mpi_code = MPI_Type_commit(&span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_commit failed", mpi_code) *new_type = span_type; @@ -1056,16 +1029,15 @@ done: HMPI_DONE_ERROR(FAIL, "MPI_Type_free failed", mpi_code) FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_mpio_span_hyper_type() */ +} /* end H5S__mpio_span_hyper_type() */ /*------------------------------------------------------------------------- - * Function: H5S_obtain_datatype + * Function: H5S__obtain_datatype * - * Purpose: Obtain an MPI derived datatype based on span-tree - * implementation + * Purpose: Obtain an MPI derived datatype for span-tree hyperslab selection * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *span_type the MPI type corresponding to the selection * @@ -1074,11 +1046,11 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, +H5S__obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, const MPI_Datatype *elmt_type, MPI_Datatype *span_type, size_t elmt_size) { 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 */ + size_t outercount; /* 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 */ hbool_t span_type_valid = FALSE; /* Whether the span_type MPI datatypes is valid */ @@ -1089,7 +1061,7 @@ H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, int mpi_code; /* MPI return status code */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(span); @@ -1129,16 +1101,14 @@ H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, blocklen[outercount] = (int)tspan->nelem; tspan = tspan->next; - if (bigio_count < blocklen[outercount]) { + if(bigio_count < blocklen[outercount]) large_block = TRUE; /* at least one block type is large, so set this flag to true */ - } outercount++; } /* end while */ /* Everything fits into integers, so cast them and use hindexed */ - if (bigio_count >= outercount && large_block == FALSE) { - + if(bigio_count >= outercount && large_block == FALSE) { if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hindexed((int)outercount, blocklen, disp, *elmt_type, span_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_create_hindexed failed", mpi_code) span_type_valid = TRUE; @@ -1150,7 +1120,7 @@ H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, MPI_Datatype temp_type = MPI_DATATYPE_NULL, outer_type = MPI_DATATYPE_NULL; /* create the block type from elmt_type while checking the 32 bit int limit */ if (blocklen[i] > bigio_count) { - if (H5S_mpio_create_large_type (blocklen[i], 0, *elmt_type, &temp_type) < 0) { + if (H5S__mpio_create_large_type (blocklen[i], 0, *elmt_type, &temp_type) < 0) { HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't create a large element datatype in span_hyper selection") } @@ -1233,7 +1203,7 @@ H5S_obtain_datatype(const hsize_t *down, H5S_hyper_span_t *span, blocklen[outercount] = 1; /* Generate MPI datatype for next dimension down */ - if(H5S_obtain_datatype(down + 1, tspan->down->head, elmt_type, &down_type, elmt_size) < 0) + if(H5S__obtain_datatype(down + 1, tspan->down->head, elmt_type, &down_type, elmt_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_BADTYPE, FAIL, "couldn't obtain MPI derived data type") /* Build the MPI datatype for this node */ @@ -1291,7 +1261,7 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_obtain_datatype() */ +} /* end H5S__obtain_datatype() */ /*------------------------------------------------------------------------- @@ -1300,7 +1270,7 @@ done: * Purpose: Translate an HDF5 dataspace selection into an MPI type. * Currently handle only hyperslab and "all" selections. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Outputs: *new_type the MPI type corresponding to the selection * *count how many objects of the new_type in selection @@ -1312,7 +1282,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type, +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) { @@ -1333,10 +1303,10 @@ 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) { + 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) + 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; @@ -1346,7 +1316,7 @@ 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) + 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; @@ -1361,29 +1331,28 @@ H5S_mpio_space_type(const H5S_t *space, size_t elmt_size, MPI_Datatype *new_type else { switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: - if(H5S_mpio_none_type(new_type, count, is_derived_type) < 0) + 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) + 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) + 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_hyper_type(space, elmt_size, new_type, count, is_derived_type) < 0) + 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) + 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") - } /* end else */ break; case H5S_SEL_ERROR: @@ -1407,12 +1376,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5S_mpio_create_large_type + * Function: H5S__mpio_create_large_type * - * Purpose: Create a large datatype of size larger than what a 32 bit integer + * Purpose: Create a large datatype of size larger than what a 32 bit integer * can hold. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * *new_type the new datatype created * @@ -1420,10 +1389,9 @@ done: * *------------------------------------------------------------------------- */ -static herr_t H5S_mpio_create_large_type (hsize_t num_elements, - MPI_Aint stride_bytes, - MPI_Datatype old_type, - MPI_Datatype *new_type) +static herr_t +H5S__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 */ @@ -1434,7 +1402,7 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements, MPI_Aint disp[2], old_extent; herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Calculate how many Big MPI datatypes are needed to represent the buffer */ num_big_types = (int)(num_elements/bigio_count); @@ -1447,41 +1415,23 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements, * use type_hvector to create the type with the displacement provided */ if (0 == stride_bytes) { - if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, - old_type, - &inner_type))) { + if(MPI_SUCCESS != (mpi_code = MPI_Type_contiguous(bigio_count, old_type, &inner_type))) HMPI_GOTO_ERROR(FAIL, "MPI_Type_contiguous failed", mpi_code) - } - } - else { - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector (bigio_count, - 1, - stride_bytes, - old_type, - &inner_type))) { + } /* end if */ + else + if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector(bigio_count, 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) - } - } - else { - if(MPI_SUCCESS != (mpi_code = MPI_Type_create_hvector (num_big_types, - 1, - stride_bytes, - inner_type, - &outer_type))) { + } /* 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) - } - } MPI_Type_free(&inner_type); @@ -1489,23 +1439,13 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements, * 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(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) - } - } - 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))) { + } /* 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) - } - } /* 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 @@ -1522,28 +1462,25 @@ static herr_t H5S_mpio_create_large_type (hsize_t num_elements, 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[1] = (old_extent + stride_bytes) * num_big_types * (MPI_Aint)bigio_count; - 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); MPI_Type_free(&leftover_type); - } - else { + } /* end if */ + else /* There are no remaining bytes so just set the new type to * the outer type created */ *new_type = outer_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 H5S_mpio_create_large_type */ +} /* end H5S__mpio_create_large_type() */ #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Snone.c b/src/H5Snone.c index a8aaf7e..c867e67 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -18,166 +18,197 @@ * Purpose: "None" selection dataspace I/O functions. */ +/****************/ +/* Module Setup */ +/****************/ + #include "H5Smodule.h" /* This source code file is part of the H5S module */ -#include "H5private.h" -#include "H5Eprivate.h" -#include "H5Iprivate.h" -#include "H5Spkg.h" -#include "H5VMprivate.h" -#include "H5Dprivate.h" +/***********/ +/* 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 */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ -/* Static function prototypes */ + +/********************/ +/* 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_get_seq_list(const H5S_t *space, unsigned flags, +static herr_t H5S__none_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__none_get_seq_list(const H5S_t *space, unsigned flags, 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_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, uint32_t version, uint8_t flags, +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, uint32_t version, uint8_t flags, 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 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 herr_t H5S_none_adjust_u(H5S_t *space, const hsize_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(H5S_sel_iter_t *iter, 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 herr_t H5S__none_adjust_u(H5S_t *space, const hsize_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(H5S_sel_iter_t *iter, const H5S_t *space); /* 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 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_release(H5S_sel_iter_t *sel_iter); +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_release(H5S_sel_iter_t *sel_iter); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ /* Selection properties for "none" selections */ const H5S_select_class_t H5S_sel_none[1] = {{ H5S_SEL_NONE, /* Methods on selection */ - H5S_none_copy, - H5S_none_get_seq_list, - H5S_none_release, - H5S_none_is_valid, - H5S_none_serial_size, - H5S_none_serialize, - H5S_none_deserialize, - H5S_none_bounds, - H5S_none_offset, + H5S__none_copy, + H5S__none_get_seq_list, + H5S__none_release, + H5S__none_is_valid, + H5S__none_serial_size, + H5S__none_serialize, + H5S__none_deserialize, + H5S__none_bounds, + H5S__none_offset, H5S__none_unlim_dim, NULL, - H5S_none_is_contiguous, - H5S_none_is_single, - H5S_none_is_regular, - H5S_none_adjust_u, - H5S_none_project_scalar, - H5S_none_project_simple, - H5S_none_iter_init, + H5S__none_is_contiguous, + H5S__none_is_single, + H5S__none_is_regular, + H5S__none_adjust_u, + H5S__none_project_scalar, + H5S__none_project_simple, + H5S__none_iter_init, }}; + +/*******************/ +/* Local Variables */ +/*******************/ + /* Iteration properties for "none" selections */ static const H5S_sel_iter_class_t H5S_sel_iter_none[1] = {{ H5S_SEL_NONE, /* Methods on selection iterator */ - H5S_none_iter_coords, - H5S_none_iter_block, - H5S_none_iter_nelmts, - H5S_none_iter_has_next_block, - H5S_none_iter_next, - H5S_none_iter_next_block, - H5S_none_iter_release, + H5S__none_iter_coords, + H5S__none_iter_block, + H5S__none_iter_nelmts, + H5S__none_iter_has_next_block, + H5S__none_iter_next, + H5S__none_iter_next_block, + H5S__none_iter_release, }}; + /*------------------------------------------------------------------------- - * Function: H5S_none_iter_init + * Function: H5S__none_iter_init * * Purpose: Initializes iteration information for "none" selection. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5S_none_iter_init(H5S_sel_iter_t *iter, const H5S_t H5_ATTR_UNUSED *space) +H5S__none_iter_init(H5S_sel_iter_t *iter, const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ - HDassert(space && H5S_SEL_NONE==H5S_GET_SELECT_TYPE(space)); + HDassert(space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(space)); HDassert(iter); /* Initialize type of selection iterator */ iter->type = H5S_sel_iter_none; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_iter_init() */ +} /* end H5S__none_iter_init() */ /*------------------------------------------------------------------------- - * Function: H5S_none_iter_coords + * Function: H5S__none_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5S_none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_UNUSED *coords) +H5S__none_iter_coords(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, + hsize_t H5_ATTR_UNUSED *coords) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); HDassert(coords); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_iter_coords() */ +} /* end H5S__none_iter_coords() */ /*------------------------------------------------------------------------- - * Function: H5S_none_iter_block + * Function: H5S__none_iter_block * * Purpose: Retrieve the current block of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ 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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); @@ -185,42 +216,40 @@ H5S_none_iter_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter, hsize_t H5_ATTR_U HDassert(end); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_iter_block() */ +} /* end H5S__none_iter_block() */ /*------------------------------------------------------------------------- - * Function: H5S_none_iter_nelmts + * Function: H5S__none_iter_nelmts * * Purpose: Return number of elements left to process in iterator * - * Return: non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static hsize_t -H5S_none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) +H5S__none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(0) -} /* H5S_none_iter_nelmts() */ +} /* end H5S__none_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME - H5S_none_iter_has_next_block + H5S__none_iter_has_next_block PURPOSE Check if there is another block left in the current iterator USAGE - htri_t H5S_none_iter_has_next_block(iter) + htri_t H5S__none_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure @@ -232,24 +261,24 @@ H5S_none_iter_nelmts(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) +H5S__none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_iter_has_next_block() */ +} /* end H5S__none_iter_has_next_block() */ /*-------------------------------------------------------------------------- NAME - H5S_none_iter_next + H5S__none_iter_next PURPOSE Increment selection iterator USAGE - herr_t H5S_none_iter_next(iter, nelem) + herr_t H5S__none_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator size_t nelem; IN: Number of elements to advance by RETURNS @@ -262,25 +291,25 @@ H5S_none_iter_has_next_block(const H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED nelem) +H5S__none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED nelem) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); - HDassert(nelem>0); + HDassert(nelem > 0); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_iter_next() */ +} /* end H5S__none_iter_next() */ /*-------------------------------------------------------------------------- NAME - H5S_none_iter_next_block + H5S__none_iter_next_block PURPOSE Increment selection iterator to next block USAGE - herr_t H5S_none_iter_next(iter) + herr_t H5S__none_iter_next(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure @@ -292,24 +321,24 @@ H5S_none_iter_next(H5S_sel_iter_t H5_ATTR_UNUSED *iter, size_t H5_ATTR_UNUSED ne REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) +H5S__none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_iter_next_block() */ +} /* end H5S__none_iter_next_block() */ /*-------------------------------------------------------------------------- NAME - H5S_none_iter_release + H5S__none_iter_release PURPOSE Release "none" selection iterator information for a dataspace USAGE - herr_t H5S_none_iter_release(iter) + herr_t H5S__none_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure @@ -321,24 +350,24 @@ H5S_none_iter_next_block(H5S_sel_iter_t H5_ATTR_UNUSED *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) +H5S__none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_iter_release() */ +} /* end H5S__none_iter_release() */ /*-------------------------------------------------------------------------- NAME - H5S_none_release + H5S__none_release PURPOSE Release none selection information for a dataspace USAGE - herr_t H5S_none_release(space) + herr_t H5S__none_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure @@ -350,26 +379,27 @@ H5S_none_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_release(H5S_t H5_ATTR_UNUSED * space) +H5S__none_release(H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_release() */ +} /* end H5S__none_release() */ /*-------------------------------------------------------------------------- NAME - H5S_none_copy + H5S__none_copy PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S_none_copy(dst, src) + herr_t H5S__none_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -381,9 +411,10 @@ H5S_none_release(H5S_t H5_ATTR_UNUSED * space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSED share_selection) +H5S__none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, + hbool_t H5_ATTR_UNUSED share_selection) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(src); HDassert(dst); @@ -392,17 +423,17 @@ H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE dst->select.num_elem = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S_none_copy() */ +} /* end H5S__none_copy() */ /*-------------------------------------------------------------------------- NAME - H5S_none_is_valid + H5S__none_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE - htri_t H5S_none_is_valid(space); + htri_t H5S__none_is_valid(space); H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and @@ -416,24 +447,24 @@ H5S_none_copy(H5S_t *dst, const H5S_t H5_ATTR_UNUSED *src, hbool_t H5_ATTR_UNUSE REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_none_is_valid(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_is_valid(const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); FUNC_LEAVE_NOAPI(TRUE) -} /* end H5S_none_is_valid() */ +} /* end H5S__none_is_valid() */ /*-------------------------------------------------------------------------- NAME - H5S_none_serial_size + H5S__none_serial_size PURPOSE Determine the number of bytes needed to store the serialized "none" selection information. USAGE - hssize_t H5S_none_serial_size(space) + hssize_t H5S__none_serial_size(space) H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. @@ -446,9 +477,9 @@ H5S_none_is_valid(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_serial_size(const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); @@ -457,16 +488,16 @@ H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space) * = 16 bytes */ FUNC_LEAVE_NOAPI(16) -} /* end H5S_none_serial_size() */ +} /* end H5S__none_serial_size() */ /*-------------------------------------------------------------------------- NAME - H5S_none_serialize + H5S__none_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE - herr_t H5S_none_serialize(space, p) + herr_t H5S__none_serialize(space, p) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of @@ -482,11 +513,11 @@ H5S_none_serial_size(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_serialize(const H5S_t *space, uint8_t **p) +H5S__none_serialize(const H5S_t *space, uint8_t **p) { uint8_t *pp = (*p); /* Local pointer for decoding */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); @@ -503,16 +534,16 @@ H5S_none_serialize(const H5S_t *space, uint8_t **p) *p = pp; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_serialize() */ +} /* end H5S__none_serialize() */ /*-------------------------------------------------------------------------- NAME - H5S_none_deserialize + H5S__none_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE - herr_t H5S_none_deserialize(space, version, flags, p) + herr_t H5S__none_deserialize(space, version, flags, p) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint32_t version IN: Selection version @@ -531,12 +562,12 @@ H5S_none_serialize(const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, - const uint8_t H5_ATTR_UNUSED **p) +H5S__none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, + uint8_t H5_ATTR_UNUSED flags, const uint8_t H5_ATTR_UNUSED **p) { herr_t ret_value = SUCCEED; /* return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(space); HDassert(p); @@ -548,16 +579,16 @@ H5S_none_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_A done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_none_deserialize() */ +} /* end H5S__none_deserialize() */ /*-------------------------------------------------------------------------- NAME - H5S_none_bounds + H5S__none_bounds PURPOSE Gets the bounding box containing the selection. USAGE - herr_t H5S_none_bounds(space, start, end) + herr_t H5S__none_bounds(space, start, end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box @@ -577,25 +608,26 @@ done: 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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); HDassert(start); HDassert(end); FUNC_LEAVE_NOAPI(FAIL) -} /* H5Sget_none_bounds() */ +} /* end H5Sget_none_bounds() */ /*-------------------------------------------------------------------------- NAME - H5S_none_offset + H5S__none_offset PURPOSE Gets the linear offset of the first element for the selection. USAGE - herr_t H5S_none_offset(space, offset) + herr_t H5S__none_offset(space, offset) const H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *offset; OUT: Linear offset of first element in selection RETURNS @@ -610,15 +642,15 @@ H5S_none_bounds(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *start REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset) +H5S__none_offset(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); HDassert(offset); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_offset() */ +} /* end H5S__none_offset() */ /*-------------------------------------------------------------------------- @@ -651,11 +683,11 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) /*-------------------------------------------------------------------------- NAME - H5S_none_is_contiguous + H5S__none_is_contiguous PURPOSE Check if a "none" selection is contiguous within the dataspace extent. USAGE - htri_t H5S_none_is_contiguous(space) + htri_t H5S__none_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -668,23 +700,23 @@ H5S__none_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); FUNC_LEAVE_NOAPI(FALSE) -} /* H5S_none_is_contiguous() */ +} /* end H5S__none_is_contiguous() */ /*-------------------------------------------------------------------------- NAME - H5S_none_is_single + H5S__none_is_single PURPOSE Check if a "none" selection is a single block within the dataspace extent. USAGE - htri_t H5S_none_is_single(space) + htri_t H5S__none_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -697,23 +729,23 @@ H5S_none_is_contiguous(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_none_is_single(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_is_single(const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); FUNC_LEAVE_NOAPI(FALSE) -} /* H5S_none_is_single() */ +} /* end H5S__none_is_single() */ /*-------------------------------------------------------------------------- NAME - H5S_none_is_regular + H5S__none_is_regular PURPOSE Check if a "none" selection is "regular" USAGE - htri_t H5S_none_is_regular(space) + htri_t H5S__none_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -727,15 +759,15 @@ H5S_none_is_single(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_none_is_regular(const H5S_t H5_ATTR_UNUSED *space) +H5S__none_is_regular(const H5S_t H5_ATTR_UNUSED *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); FUNC_LEAVE_NOAPI(TRUE) -} /* H5S_none_is_regular() */ +} /* end H5S__none_is_regular() */ /*-------------------------------------------------------------------------- @@ -744,7 +776,7 @@ H5S_none_is_regular(const H5S_t H5_ATTR_UNUSED *space) PURPOSE Adjust an "none" selection by subtracting an offset USAGE - herr_t H5S_none_adjust_u(space, offset) + herr_t H5S__none_adjust_u(space, offset) H5S_t *space; IN/OUT: Pointer to dataspace to adjust const hsize_t *offset; IN: Offset to subtract RETURNS @@ -757,24 +789,24 @@ H5S_none_is_regular(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *offset) +H5S__none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *offset) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); HDassert(offset); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_none_adjust_u() */ +} /* end H5S__none_adjust_u() */ /*------------------------------------------------------------------------- - * Function: H5S_none_project_scalar + * Function: H5S__none_project_scalar * * Purpose: Projects a 'none' selection into a scalar dataspace * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -782,25 +814,25 @@ H5S_none_adjust_u(H5S_t H5_ATTR_UNUSED *space, const hsize_t H5_ATTR_UNUSED *off *------------------------------------------------------------------------- */ static herr_t -H5S_none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset) +H5S__none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSED *offset) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(space)); HDassert(offset); FUNC_LEAVE_NOAPI(FAIL) -} /* H5S_none_project_scalar() */ +} /* end H5S__none_project_scalar() */ /*------------------------------------------------------------------------- - * Function: H5S_none_project_simple + * Function: H5S__none_project_simple * * Purpose: Projects an 'none' selection onto/into a simple dataspace * of a different rank * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -808,11 +840,12 @@ H5S_none_project_scalar(const H5S_t H5_ATTR_UNUSED *space, hsize_t H5_ATTR_UNUSE *------------------------------------------------------------------------- */ static herr_t -H5S_none_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(base_space && H5S_SEL_NONE == H5S_GET_SELECT_TYPE(base_space)); @@ -825,7 +858,7 @@ H5S_none_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offs done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_none_project_simple() */ +} /* end H5S__none_project_simple() */ /*-------------------------------------------------------------------------- @@ -867,7 +900,7 @@ H5S_select_none(H5S_t *space) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_none() */ +} /* end H5S_select_none() */ /*-------------------------------------------------------------------------- @@ -906,16 +939,16 @@ H5Sselect_none(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sselect_none() */ +} /* end H5Sselect_none() */ /*-------------------------------------------------------------------------- NAME - H5S_none_get_seq_list + H5S__none_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE - herr_t H5S_none_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) + herr_t H5S__none_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last @@ -941,11 +974,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, H5S_sel_iter_t H5_ATTR_UNUSED *iter, +H5S__none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED flags, 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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); @@ -964,5 +997,5 @@ H5S_none_get_seq_list(const H5S_t H5_ATTR_UNUSED *space, unsigned H5_ATTR_UNUSED *nelem = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5S_none_get_seq_list() */ +} /* end H5S__none_get_seq_list() */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index 9ad97dc..1fbfa35 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -26,8 +26,12 @@ #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 */ + /* Flags to indicate special dataspace features are active */ #define H5S_VALID_MAX 0x01 #define H5S_VALID_PERM 0x02 @@ -77,6 +81,7 @@ struct H5S_extent_t { /* * Dataspace selection information */ + /* Node in point selection list (typedef'd in H5Sprivate.h) */ struct H5S_pnt_node_t { hsize_t *pnt; /* Pointer to a selected point */ @@ -88,9 +93,9 @@ typedef struct { H5S_pnt_node_t *head; /* Pointer to head of point list */ } H5S_pnt_list_t; -/* Information about new-style hyperslab spans */ +/* Information about hyperslab spans */ -/* Information a particular hyperslab span */ +/* Information a particular hyperslab span (typedef'd in H5Sprivate.h) */ struct H5S_hyper_span_t { hsize_t low, high; /* Low & high bounds of span */ hsize_t nelem; /* Number of elements in span (only needed during I/O) */ @@ -217,9 +222,11 @@ struct H5S_t { /* Selection iteration methods */ /* Method to retrieve the current coordinates of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, hsize_t *coords); +typedef herr_t (*H5S_sel_iter_coords_func_t)(const H5S_sel_iter_t *iter, + hsize_t *coords); /* Method to retrieve the current block of iterator for current selection */ -typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end); +typedef herr_t (*H5S_sel_iter_block_func_t)(const H5S_sel_iter_t *iter, + hsize_t *start, hsize_t *end); /* Method to determine number of elements left in iterator for current selection */ typedef hsize_t (*H5S_sel_iter_nelmts_func_t)(const H5S_sel_iter_t *iter); /* Method to determine if there are more blocks left in the current selection */ @@ -269,8 +276,8 @@ H5_DLLVAR const H5S_select_class_t H5S_sel_point[1]; 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, +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); /* Operations on selections */ @@ -280,8 +287,8 @@ H5_DLL herr_t H5S__hyper_subtract(H5S_t *space, H5S_t *subtract_space); /* Testing functions */ #ifdef H5S_TESTING -H5_DLL htri_t H5S_select_shape_same_test(hid_t sid1, hid_t sid2); -H5_DLL htri_t H5S_get_rebuild_status_test(hid_t space_id); +H5_DLL htri_t H5S__select_shape_same_test(hid_t sid1, hid_t sid2); +H5_DLL htri_t H5S__get_rebuild_status_test(hid_t space_id); #endif /* H5S_TESTING */ #endif /*_H5Spkg_H*/ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index aea7d5c..11cf448 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -18,87 +18,124 @@ * Purpose: Point selection dataspace I/O functions. */ +/****************/ +/* Module Setup */ +/****************/ + #include "H5Smodule.h" /* This source code file is part of the H5S module */ -#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 functions */ -#include "H5Spkg.h" /* Dataspace functions */ -#include "H5VMprivate.h" /* Vector functions */ +/***********/ +/* 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 */ + + +/****************/ +/* Local Macros */ +/****************/ + -/* Static function prototypes */ +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ /* Selection callbacks */ -static herr_t H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); -static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags, +static herr_t H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection); +static herr_t H5S__point_get_seq_list(const H5S_t *space, unsigned flags, 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_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, uint32_t version, uint8_t flags, +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, uint32_t version, uint8_t flags, 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 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 herr_t H5S_point_adjust_u(H5S_t *space, const hsize_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(H5S_sel_iter_t *iter, 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 herr_t H5S__point_adjust_u(H5S_t *space, const hsize_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(H5S_sel_iter_t *iter, const H5S_t *space); /* 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 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_release(H5S_sel_iter_t *sel_iter); +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_release(H5S_sel_iter_t *sel_iter); + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ /* Selection properties for point selections */ const H5S_select_class_t H5S_sel_point[1] = {{ H5S_SEL_POINTS, /* Methods on selection */ - H5S_point_copy, - H5S_point_get_seq_list, - H5S_point_release, - H5S_point_is_valid, - H5S_point_serial_size, - H5S_point_serialize, - H5S_point_deserialize, - H5S_point_bounds, - H5S_point_offset, + H5S__point_copy, + H5S__point_get_seq_list, + H5S__point_release, + H5S__point_is_valid, + H5S__point_serial_size, + H5S__point_serialize, + H5S__point_deserialize, + H5S__point_bounds, + H5S__point_offset, H5S__point_unlim_dim, NULL, - H5S_point_is_contiguous, - H5S_point_is_single, - H5S_point_is_regular, - H5S_point_adjust_u, - H5S_point_project_scalar, - H5S_point_project_simple, - H5S_point_iter_init, + H5S__point_is_contiguous, + H5S__point_is_single, + H5S__point_is_regular, + H5S__point_adjust_u, + H5S__point_project_scalar, + H5S__point_project_simple, + H5S__point_iter_init, }}; + +/*******************/ +/* Local Variables */ +/*******************/ + /* Iteration properties for point selections */ static const H5S_sel_iter_class_t H5S_sel_iter_point[1] = {{ H5S_SEL_POINTS, /* Methods on selection iterator */ - H5S_point_iter_coords, - H5S_point_iter_block, - H5S_point_iter_nelmts, - H5S_point_iter_has_next_block, - H5S_point_iter_next, - H5S_point_iter_next_block, - H5S_point_iter_release, + H5S__point_iter_coords, + H5S__point_iter_block, + H5S__point_iter_nelmts, + H5S__point_iter_has_next_block, + H5S__point_iter_next, + H5S__point_iter_next_block, + H5S__point_iter_release, }}; /* Declare a free list to manage the H5S_pnt_node_t struct */ @@ -107,93 +144,88 @@ H5FL_DEFINE_STATIC(H5S_pnt_node_t); /* Declare a free list to manage the H5S_pnt_list_t struct */ H5FL_DEFINE_STATIC(H5S_pnt_list_t); + /*------------------------------------------------------------------------- - * Function: H5S_point_iter_init + * Function: H5S__point_iter_init * * Purpose: Initializes iteration information for point selection. * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) +H5S__point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ - HDassert(space && H5S_SEL_POINTS==H5S_GET_SELECT_TYPE(space)); + HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space)); HDassert(iter); /* Initialize the number of points to iterate over */ - iter->elmt_left=space->select.num_elem; + iter->elmt_left = space->select.num_elem; /* Start at the head of the list of points */ iter->u.pnt.curr=space->select.sel_info.pnt_lst->head; /* Initialize type of selection iterator */ - iter->type=H5S_sel_iter_point; + iter->type = H5S_sel_iter_point; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_init() */ +} /* end H5S__point_iter_init() */ /*------------------------------------------------------------------------- - * Function: H5S_point_iter_coords + * Function: H5S__point_iter_coords * * Purpose: Retrieve the current coordinates of iterator for current * selection * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Tuesday, April 22, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5S_point_iter_coords (const H5S_sel_iter_t *iter, hsize_t *coords) +H5S__point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); HDassert(coords); /* Copy the offset of the current point */ - HDmemcpy(coords,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); + HDmemcpy(coords, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_coords() */ +} /* 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 * - * Return: non-negative on success, negative on failure + * Return: Non-negative on success, negative on failure * * Programmer: Quincey Koziol * Monday, June 2, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ static herr_t -H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) +H5S__point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); @@ -201,46 +233,44 @@ H5S_point_iter_block (const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) HDassert(end); /* Copy the current point as a block */ - HDmemcpy(start,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); - HDmemcpy(end,iter->u.pnt.curr->pnt,sizeof(hsize_t)*iter->rank); + HDmemcpy(start, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank); + HDmemcpy(end, iter->u.pnt.curr->pnt, sizeof(hsize_t) * iter->rank); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_block() */ +} /* end H5S__point_iter_block() */ /*------------------------------------------------------------------------- - * Function: H5S_point_iter_nelmts + * Function: H5S__point_iter_nelmts * * Purpose: Return number of elements left to process in iterator * - * Return: non-negative number of elements on success, zero on failure + * Return: Non-negative number of elements on success, zero on failure * * Programmer: Quincey Koziol * Tuesday, June 16, 1998 * - * Modifications: - * *------------------------------------------------------------------------- */ static hsize_t -H5S_point_iter_nelmts (const H5S_sel_iter_t *iter) +H5S__point_iter_nelmts(const H5S_sel_iter_t *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(iter->elmt_left) -} /* H5S_point_iter_nelmts() */ +} /* end H5S__point_iter_nelmts() */ /*-------------------------------------------------------------------------- NAME - H5S_point_iter_has_next_block + H5S__point_iter_has_next_block PURPOSE Check if there is another block left in the current iterator USAGE - htri_t H5S_point_iter_has_next_block(iter) + htri_t H5S__point_iter_has_next_block(iter) const H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative (TRUE/FALSE) on success/Negative on failure @@ -252,31 +282,31 @@ H5S_point_iter_nelmts (const H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter) +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_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ 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) -} /* H5S_point_iter_has_next_block() */ +} /* end H5S__point_iter_has_next_block() */ /*-------------------------------------------------------------------------- NAME - H5S_point_iter_next + H5S__point_iter_next PURPOSE Increment selection iterator USAGE - herr_t H5S_point_iter_next(iter, nelem) + herr_t H5S__point_iter_next(iter, nelem) H5S_sel_iter_t *iter; IN: Pointer to selection iterator size_t nelem; IN: Number of elements to advance by RETURNS @@ -289,31 +319,31 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) +H5S__point_iter_next(H5S_sel_iter_t *iter, size_t nelem) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); - HDassert(nelem>0); + HDassert(nelem > 0); /* Increment the iterator */ - while(nelem>0) { - iter->u.pnt.curr=iter->u.pnt.curr->next; + while(nelem > 0) { + iter->u.pnt.curr = iter->u.pnt.curr->next; nelem--; } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_next() */ +} /* end H5S__point_iter_next() */ /*-------------------------------------------------------------------------- NAME - H5S_point_iter_next_block + H5S__point_iter_next_block PURPOSE Increment selection iterator to next block USAGE - herr_t H5S_point_iter_next_block(iter) + herr_t H5S__point_iter_next_block(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure @@ -325,27 +355,27 @@ H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_iter_next_block(H5S_sel_iter_t *iter) +H5S__point_iter_next_block(H5S_sel_iter_t *iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); /* Increment the iterator */ - iter->u.pnt.curr=iter->u.pnt.curr->next; + iter->u.pnt.curr = iter->u.pnt.curr->next; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_next_block() */ +} /* end H5S__point_iter_next_block() */ /*-------------------------------------------------------------------------- NAME - H5S_point_iter_release + H5S__point_iter_release PURPOSE Release point selection iterator information for a dataspace USAGE - herr_t H5S_point_iter_release(iter) + herr_t H5S__point_iter_release(iter) H5S_sel_iter_t *iter; IN: Pointer to selection iterator RETURNS Non-negative on success/Negative on failure @@ -357,24 +387,24 @@ H5S_point_iter_next_block(H5S_sel_iter_t *iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter) +H5S__point_iter_release(H5S_sel_iter_t H5_ATTR_UNUSED * iter) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(iter); FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_iter_release() */ +} /* end H5S__point_iter_release() */ /*-------------------------------------------------------------------------- NAME - H5S_point_add + H5S__point_add PURPOSE Add a series of elements to a point selection USAGE - herr_t H5S_point_add(space, num_elem, coord) + herr_t H5S__point_add(space, num_elem, coord) H5S_t *space; IN: Dataspace of selection to modify size_t num_elem; IN: Number of elements in COORD array. const hsize_t *coord[]; IN: The location of each element selected @@ -388,14 +418,15 @@ H5S_point_iter_release (H5S_sel_iter_t H5_ATTR_UNUSED * iter) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_add(H5S_t *space, H5S_seloper_t op, size_t num_elem, const hsize_t *coord) +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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC + /* Sanity checks */ HDassert(space); HDassert(num_elem > 0); HDassert(coord); @@ -469,16 +500,16 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_add() */ +} /* end H5S__point_add() */ /*-------------------------------------------------------------------------- NAME - H5S_point_release + H5S__point_release PURPOSE Release point selection information for a dataspace USAGE - herr_t H5S_point_release(space) + herr_t H5S__point_release(space) H5S_t *space; IN: Pointer to dataspace RETURNS Non-negative on success/Negative on failure @@ -490,7 +521,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_release (H5S_t *space) +H5S__point_release(H5S_t *space) { H5S_pnt_node_t *curr, *next; /* Point selection nodes */ @@ -515,7 +546,7 @@ H5S_point_release (H5S_t *space) space->select.num_elem = 0; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_release() */ +} /* end H5S__point_release() */ /*-------------------------------------------------------------------------- @@ -539,10 +570,7 @@ H5S_point_release (H5S_t *space) array elements are iterated through when I/O is performed. Duplicate coordinates are not checked for. The selection operator, OP, determines how the new selection is to be combined with the existing selection for - the dataspace. Currently, only H5S_SELECT_SET is supported, which replaces - the existing selection with the one defined in this call. When operators - other than H5S_SELECT_SET are used to combine a new selection with an - existing selection, the selection ordering is reset to 'C' array ordering. + the dataspace. GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -552,9 +580,9 @@ herr_t 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_NOINIT + FUNC_ENTER_NOAPI(FAIL) /* Check args */ HDassert(space); @@ -573,7 +601,7 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate element information") /* 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 */ @@ -581,18 +609,19 @@ H5S_select_elements(H5S_t *space, H5S_seloper_t op, size_t num_elem, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_elements() */ +} /* end H5S_select_elements() */ /*-------------------------------------------------------------------------- NAME - H5S_point_copy + H5S__point_copy PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S_point_copy(dst, src) + herr_t H5S__point_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t share_selection; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -604,12 +633,12 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection) +H5S__point_copy(H5S_t *dst, const H5S_t *src, hbool_t H5_ATTR_UNUSED share_selection) { H5S_pnt_node_t *curr, *new_node, *new_tail; /* Point information nodes */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC HDassert(src); HDassert(dst); @@ -660,18 +689,18 @@ done: } /* end if */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_point_copy() */ +} /* end H5S__point_copy() */ /*-------------------------------------------------------------------------- NAME - H5S_point_is_valid + H5S__point_is_valid PURPOSE Check whether the selection fits within the extent, with the current offset defined. USAGE - htri_t H5S_point_is_valid(space); - H5S_t *space; IN: Dataspace pointer to query + htri_t H5S__point_is_valid(space); + const H5S_t *space; IN: Dataspace pointer to query RETURNS TRUE if the selection fits within the extent, FALSE if it does not and Negative on an error. @@ -684,13 +713,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_point_is_valid (const H5S_t *space) +H5S__point_is_valid(const H5S_t *space) { H5S_pnt_node_t *curr; /* Point information nodes */ unsigned u; /* Counter */ htri_t ret_value = TRUE; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); @@ -711,7 +740,7 @@ H5S_point_is_valid (const H5S_t *space) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_point_is_valid() */ +} /* end H5S__point_is_valid() */ /*-------------------------------------------------------------------------- @@ -750,18 +779,18 @@ H5Sget_select_elem_npoints(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_elem_npoints() */ +} /* end H5Sget_select_elem_npoints() */ /*-------------------------------------------------------------------------- NAME - H5S_point_serial_size + H5S__point_serial_size PURPOSE Determine the number of bytes needed to store the serialized point selection information. USAGE - hssize_t H5S_point_serial_size(space) - H5S_t *space; IN: Dataspace pointer to query + hssize_t H5S__point_serial_size(space) + const H5S_t *space; IN: Dataspace pointer to query RETURNS The number of bytes required on success, negative on an error. DESCRIPTION @@ -773,11 +802,11 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static hssize_t -H5S_point_serial_size (const H5S_t *space) +H5S__point_serial_size(const H5S_t *space) { hssize_t ret_value = -1; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); @@ -792,16 +821,16 @@ H5S_point_serial_size (const H5S_t *space) ret_value += (4 * space->extent.rank) * (hssize_t)H5S_GET_SELECT_NPOINTS(space); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_point_serial_size() */ +} /* end H5S__point_serial_size() */ /*-------------------------------------------------------------------------- NAME - H5S_point_serialize + H5S__point_serialize PURPOSE Serialize the current selection into a user-provided buffer. USAGE - herr_t H5S_point_serialize(space, p) + herr_t H5S__point_serialize(space, p) const H5S_t *space; IN: Dataspace with selection to serialize uint8_t **p; OUT: Pointer to buffer to put serialized selection. Will be advanced to end of @@ -817,15 +846,15 @@ H5S_point_serial_size (const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_serialize (const H5S_t *space, uint8_t **p) +H5S__point_serialize(const H5S_t *space, uint8_t **p) { H5S_pnt_node_t *curr; /* Point information nodes */ uint8_t *pp = (*p); /* Local pointer for decoding */ - uint8_t *lenp; /* pointer to length location for later storage */ - uint32_t len=0; /* number of bytes used */ - unsigned u; /* local counting variable */ + uint8_t *lenp; /* Pointer to length location for later storage */ + uint32_t len = 0; /* Number of bytes used */ + unsigned u; /* Local counting variable */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); @@ -841,23 +870,23 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) /* Encode number of dimensions */ UINT32ENCODE(pp, (uint32_t)space->extent.rank); - len+=4; + len += 4; /* Encode number of elements */ UINT32ENCODE(pp, (uint32_t)space->select.num_elem); - len+=4; + len += 4; /* Encode each point in selection */ - curr=space->select.sel_info.pnt_lst->head; - while(curr!=NULL) { + 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; + len += 4 * space->extent.rank; /* Encode each point */ - for(u=0; uextent.rank; u++) + for(u = 0; u < space->extent.rank; u++) UINT32ENCODE(pp, (uint32_t)curr->pnt[u]); - curr=curr->next; + curr = curr->next; } /* end while */ /* Encode length */ @@ -867,16 +896,16 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) *p = pp; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_serialize() */ +} /* end H5S__point_serialize() */ /*-------------------------------------------------------------------------- NAME - H5S_point_deserialize + H5S__point_deserialize PURPOSE Deserialize the current selection from a user-provided buffer. USAGE - herr_t H5S_point_deserialize(space, p) + herr_t H5S__point_deserialize(space, p) H5S_t *space; IN/OUT: Dataspace pointer to place selection into uint32_t version IN: Selection version @@ -895,10 +924,9 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, +H5S__point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags, const uint8_t **p) { - H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */ hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */ const uint8_t *pp = (*p); /* Local pointer for decoding */ size_t num_elem = 0; /* Number of elements in selection */ @@ -906,7 +934,7 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ unsigned i, j; /* local counting variables */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -928,7 +956,7 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ UINT32DECODE(pp, *tcoord); /* Select points */ - if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0) + if(H5S_select_elements(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 */ @@ -940,17 +968,17 @@ done: H5MM_xfree(coord); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_deserialize() */ +} /* end H5S__point_deserialize() */ /*-------------------------------------------------------------------------- NAME - H5S_get_select_elem_pointlist + H5S__get_select_elem_pointlist PURPOSE Get the list of element points currently selected USAGE - herr_t H5S_get_select_elem_pointlist(space, hsize_t *buf) - H5S_t *space; IN: Dataspace pointer of selection to query + herr_t H5S__get_select_elem_pointlist(space, hsize_t *buf) + const H5S_t *space; IN: Dataspace pointer of selection to query hsize_t startpoint; IN: Element point to start with hsize_t numpoints; IN: Number of element points to get hsize_t *buf; OUT: List of element points selected @@ -973,12 +1001,13 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoints, hsize_t *buf) +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 */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); HDassert(buf); @@ -1004,7 +1033,7 @@ H5S_get_select_elem_pointlist(H5S_t *space, hsize_t startpoint, hsize_t numpoint } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_get_select_elem_pointlist() */ +} /* end H5S__get_select_elem_pointlist() */ /*-------------------------------------------------------------------------- @@ -1054,20 +1083,20 @@ H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, 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); + ret_value = H5S__get_select_elem_pointlist(space, startpoint, numpoints, buf); done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_elem_pointlist() */ +} /* end H5Sget_select_elem_pointlist() */ /*-------------------------------------------------------------------------- NAME - H5S_point_bounds + H5S__point_bounds PURPOSE Gets the bounding box containing the selection. USAGE - herr_t H5S_point_bounds(space, start, end) + herr_t H5S__point_bounds(space, start, end) H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *start; OUT: Starting coordinate of bounding box hsize_t *end; OUT: Opposite coordinate of bounding box @@ -1088,14 +1117,14 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) +H5S__point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) { H5S_pnt_node_t *node; /* Point node */ unsigned rank; /* Dataspace rank */ unsigned u; /* Local index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(space); @@ -1129,16 +1158,16 @@ H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_bounds() */ +} /* end H5S__point_bounds() */ /*-------------------------------------------------------------------------- NAME - H5S_point_offset + H5S__point_offset PURPOSE Gets the linear offset of the first element for the selection. USAGE - herr_t H5S_point_offset(space, offset) + herr_t H5S__point_offset(space, offset) const H5S_t *space; IN: Dataspace pointer of selection to query hsize_t *offset; OUT: Linear offset of first element in selection RETURNS @@ -1153,7 +1182,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_offset(const H5S_t *space, hsize_t *offset) +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 */ @@ -1162,7 +1191,7 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset) int i; /* index variable */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_STATIC HDassert(space); HDassert(offset); @@ -1193,7 +1222,7 @@ H5S_point_offset(const H5S_t *space, hsize_t *offset) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_offset() */ +} /* end H5S__point_offset() */ /*-------------------------------------------------------------------------- @@ -1227,11 +1256,11 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) /*-------------------------------------------------------------------------- NAME - H5S_point_is_contiguous + H5S__point_is_contiguous PURPOSE Check if a point selection is contiguous within the dataspace extent. USAGE - htri_t H5S_point_is_contiguous(space) + htri_t H5S__point_is_contiguous(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -1247,31 +1276,31 @@ H5S__point_unlim_dim(const H5S_t H5_ATTR_UNUSED *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_point_is_contiguous(const H5S_t *space) +H5S__point_is_contiguous(const H5S_t *space) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely contiguous */ - if(space->select.num_elem==1) - ret_value=TRUE; + 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 */ - ret_value=FALSE; + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_is_contiguous() */ +} /* end H5S__point_is_contiguous() */ /*-------------------------------------------------------------------------- NAME - H5S_point_is_single + H5S__point_is_single PURPOSE Check if a point selection is single within the dataspace extent. USAGE - htri_t H5S_point_is_single(space) + htri_t H5S__point_is_single(space) H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -1284,31 +1313,31 @@ H5S_point_is_contiguous(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_point_is_single(const H5S_t *space) +H5S__point_is_single(const H5S_t *space) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); /* One point is definitely 'single' :-) */ - if(space->select.num_elem==1) - ret_value=TRUE; + if(space->select.num_elem == 1) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_is_single() */ +} /* end H5S__point_is_single() */ /*-------------------------------------------------------------------------- NAME - H5S_point_is_regular + H5S__point_is_regular PURPOSE Check if a point selection is "regular" USAGE - htri_t H5S_point_is_regular(space) + htri_t H5S__point_is_regular(space) const H5S_t *space; IN: Dataspace pointer to check RETURNS TRUE/FALSE/FAIL @@ -1324,32 +1353,32 @@ H5S_point_is_single(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static htri_t -H5S_point_is_regular(const H5S_t *space) +H5S__point_is_regular(const H5S_t *space) { htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Check args */ HDassert(space); /* Only simple check for regular points for now... */ - if(space->select.num_elem==1) - ret_value=TRUE; + if(space->select.num_elem == 1) + ret_value = TRUE; else - ret_value=FALSE; + ret_value = FALSE; FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_is_regular() */ +} /* end H5S__point_is_regular() */ /*-------------------------------------------------------------------------- NAME - H5S_point_adjust_u + H5S__point_adjust_u PURPOSE Adjust a "point" selection by subtracting an offset USAGE - herr_t H5S_point_adjust_u(space, offset) + herr_t H5S__point_adjust_u(space, offset) H5S_t *space; IN/OUT: Pointer to dataspace to adjust const hsize_t *offset; IN: Offset to subtract RETURNS @@ -1362,12 +1391,12 @@ H5S_point_is_regular(const H5S_t *space) REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_adjust_u(H5S_t *space, const hsize_t *offset) +H5S__point_adjust_u(H5S_t *space, const hsize_t *offset) { H5S_pnt_node_t *node; /* Point node */ unsigned rank; /* Dataspace rank */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR HDassert(space); HDassert(offset); @@ -1392,16 +1421,16 @@ H5S_point_adjust_u(H5S_t *space, const hsize_t *offset) } /* end while */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_point_adjust_u() */ +} /* end H5S__point_adjust_u() */ /*------------------------------------------------------------------------- - * Function: H5S_point_project_scalar + * Function: H5S__point_project_scalar * * Purpose: Projects a single element point selection into a scalar * dataspace * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -1409,12 +1438,12 @@ H5S_point_adjust_u(H5S_t *space, const hsize_t *offset) *------------------------------------------------------------------------- */ static herr_t -H5S_point_project_scalar(const H5S_t *space, hsize_t *offset) +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 */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(space)); @@ -1428,20 +1457,20 @@ H5S_point_project_scalar(const H5S_t *space, hsize_t *offset) 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); + *offset = H5VM_array_offset(space->extent.rank, space->extent.size, node->pnt); done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_project_scalar() */ +} /* 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 * - * Return: non-negative on success, negative on failure. + * Return: Non-negative on success, negative on failure. * * Programmer: Quincey Koziol * Sunday, July 18, 2010 @@ -1449,7 +1478,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *offset) +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 */ @@ -1457,7 +1486,7 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off unsigned rank_diff; /* Difference in ranks between spaces */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(base_space && H5S_SEL_POINTS == H5S_GET_SELECT_TYPE(base_space)); @@ -1482,7 +1511,7 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off /* Calculate offset of selection in projected buffer */ HDmemset(block, 0, sizeof(block)); HDmemcpy(block, base_space->select.sel_info.pnt_lst->head->pnt, sizeof(hsize_t) * rank_diff); - *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); + *offset = H5VM_array_offset(base_space->extent.rank, base_space->extent.size, block); /* Iterate through base space's point nodes, copying the point information */ base_node = base_space->select.sel_info.pnt_lst->head; @@ -1559,7 +1588,7 @@ H5S_point_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *off done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_point_project_simple() */ +} /* end H5S__point_project_simple() */ /*-------------------------------------------------------------------------- @@ -1620,16 +1649,16 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem, done: FUNC_LEAVE_API(ret_value) -} /* H5Sselect_elements() */ +} /* end H5Sselect_elements() */ /*-------------------------------------------------------------------------- NAME - H5S_point_get_seq_list + H5S__point_get_seq_list PURPOSE Create a list of offsets & lengths for a selection USAGE - herr_t H5S_point_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) + herr_t H5S__point_get_seq_list(space,flags,iter,maxseq,maxelem,nseq,nelem,off,len) H5S_t *space; IN: Dataspace containing selection to use. unsigned flags; IN: Flags for extra information about operation H5S_sel_iter_t *iter; IN/OUT: Selection iterator describing last @@ -1655,14 +1684,14 @@ done: REVISION LOG --------------------------------------------------------------------------*/ static herr_t -H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, +H5S__point_get_seq_list(const H5S_t *space, unsigned flags, 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 */ - hsize_t dims[H5O_LAYOUT_NDIMS]; /* Total size of memory buf */ + hsize_t dims[H5S_MAX_RANK]; /* Total size of memory buf */ int ndims; /* Dimensionality of space*/ hsize_t acc; /* Coordinate accumulator */ hsize_t loc; /* Coordinate offset */ @@ -1670,7 +1699,7 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, int i; /* Local index variable */ herr_t ret_value=SUCCEED; /* return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Check args */ HDassert(space); @@ -1758,5 +1787,5 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter, done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_point_get_seq_list() */ +} /* end H5S__point_get_seq_list() */ diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h index 32ac51a..24db889 100644 --- a/src/H5Sprivate.h +++ b/src/H5Sprivate.h @@ -17,9 +17,6 @@ #ifndef _H5Sprivate_H #define _H5Sprivate_H -/* Early typedefs to avoid circular dependencies */ -typedef struct H5S_t H5S_t; - /* Include package's public header */ #include "H5Spublic.h" @@ -30,7 +27,6 @@ typedef struct H5S_t H5S_t; #include "H5private.h" /* Generic Functions */ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ @@ -68,14 +64,14 @@ typedef struct { /* 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 off[H5S_MAX_RANK]; /* Offset in span node (used as position for regular hyperslabs) */ 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 which have been "flattened" out + * 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 */ + 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 */ @@ -196,6 +192,12 @@ typedef struct H5S_sel_iter_op_t { #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; +struct H5O_loc_t; + +/* Early typedef to avoid circular dependencies */ +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); @@ -207,7 +209,7 @@ 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, H5O_t *oh, unsigned update_flags, H5S_t *ds); +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); @@ -314,7 +316,7 @@ 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, + hbool_t do_permute, hsize_t **permute_map, hbool_t * is_permuted); #endif /* H5_HAVE_PARALLEL */ diff --git a/src/H5Spublic.h b/src/H5Spublic.h index d7a5d29..b7129ca 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -79,23 +79,22 @@ typedef enum H5S_seloper_t { typedef enum { H5S_SEL_ERROR = -1, /* Error */ H5S_SEL_NONE = 0, /* Nothing selected */ - H5S_SEL_POINTS = 1, /* Sequence of points selected */ - H5S_SEL_HYPERSLABS = 2, /* "New-style" hyperslab selection defined */ + 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; +} H5S_sel_type; #ifdef __cplusplus extern "C" { #endif -/* Functions in H5S.c */ +/* 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[]); + 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[]); + const hsize_t dims[], const hsize_t max[]); H5_DLL hid_t H5Scopy(hid_t space_id); H5_DLL herr_t H5Sclose(hid_t space_id); H5_DLL herr_t H5Sencode(hid_t obj_id, void *buf, size_t *nalloc); @@ -103,51 +102,47 @@ H5_DLL hid_t H5Sdecode(const void *buf); H5_DLL hssize_t H5Sget_simple_extent_npoints(hid_t space_id); 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[]); + hsize_t maxdims[]); H5_DLL htri_t H5Sis_simple(hid_t space_id); +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 H5Sget_select_bounds(hid_t spaceid, hsize_t start[], + hsize_t end[]); +H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); +H5_DLL herr_t H5Sselect_all(hid_t spaceid); +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[]); + const hsize_t start[], const hsize_t _stride[], const hsize_t count[], + const hsize_t _block[]); /* #define NEW_HYPERSLAB_API */ /* Note that these haven't been working for a while and were never * publicly released - QAK */ #ifdef NEW_HYPERSLAB_API 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 H5Sselect_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); + const hsize_t start[], const hsize_t _stride[], const hsize_t count[], + const hsize_t _block[]); +H5_DLL herr_t H5Sselect_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); #endif /* NEW_HYPERSLAB_API */ -H5_DLL herr_t H5Sselect_elements(hid_t space_id, H5S_seloper_t op, - size_t num_elem, const hsize_t *coord); -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); -H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); -H5_DLL herr_t H5Sselect_all(hid_t spaceid); -H5_DLL herr_t H5Sselect_none(hid_t spaceid); -H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); -H5_DLL htri_t H5Sselect_valid(hid_t spaceid); 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 hssize_t H5Sget_select_elem_npoints(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 herr_t H5Sget_select_elem_pointlist(hid_t spaceid, hsize_t startpoint, - hsize_t numpoints, hsize_t buf[/*numpoints*/]); -H5_DLL herr_t H5Sget_select_bounds(hid_t spaceid, hsize_t start[], - hsize_t end[]); -H5_DLL H5S_sel_type H5Sget_select_type(hid_t spaceid); #ifdef __cplusplus } diff --git a/src/H5Sselect.c b/src/H5Sselect.c index dd656b1..4d7fc4f 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -17,9 +17,16 @@ * Purpose: Dataspace selection functions. */ +/****************/ +/* Module Setup */ +/****************/ + #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 */ @@ -27,16 +34,40 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Spkg.h" /* Dataspaces */ -#include "H5VMprivate.h" /* Vector and array functions */ -#include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5VMprivate.h" /* Vector and array functions */ + + +/****************/ +/* Local Macros */ +/****************/ + + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ -/* Local functions */ #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); #endif /* LATER */ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + /* Declare a free list to manage the H5S_sel_iter_t struct */ H5FL_DEFINE(H5S_sel_iter_t); @@ -47,6 +78,11 @@ H5FL_SEQ_EXTERN(size_t); H5FL_SEQ_EXTERN(hsize_t); +/*******************/ +/* Local Variables */ +/*******************/ + + /*-------------------------------------------------------------------------- NAME @@ -78,13 +114,56 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) HDassert(offset); /* Copy the offset over */ - HDmemcpy(space->select.offset, offset, sizeof(hssize_t)*space->extent.rank); + HDmemcpy(space->select.offset, offset, sizeof(hssize_t) * space->extent.rank); /* Indicate that the offset was changed */ space->select.offset_changed = TRUE; FUNC_LEAVE_NOAPI(SUCCEED) -} /* H5S_select_offset() */ +} /* end H5S_select_offset() */ + + +/*-------------------------------------------------------------------------- + NAME + H5Soffset_simple + PURPOSE + Changes the offset of a selection within a simple dataspace extent + USAGE + herr_t H5Soffset_simple(space_id, offset) + hid_t space_id; IN: Dataspace object to reset + const hssize_t *offset; IN: Offset to position the selection at + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + 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 query */ + 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))) + 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)) + HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace") + if(offset == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified") + + /* Set the selection offset */ + 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() */ /*-------------------------------------------------------------------------- @@ -139,9 +218,10 @@ done: PURPOSE Copy a selection from one dataspace to another USAGE - herr_t H5S_select_copy(dst, src) + herr_t H5S_select_copy(dst, src, share_selection) H5S_t *dst; OUT: Pointer to the destination dataspace H5S_t *src; IN: Pointer to the source dataspace + hbool_t; IN: Whether to share the selection between the dataspaces RETURNS Non-negative on success/Negative on failure DESCRIPTION @@ -177,7 +257,7 @@ H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_copy() */ +} /* end H5S_select_copy() */ /*------------------------------------------------------------------------- @@ -211,7 +291,7 @@ H5S_select_release(H5S_t *ds) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_release() */ +} /* end H5S_select_release() */ /*------------------------------------------------------------------------- @@ -278,10 +358,10 @@ H5S_select_serial_size(const H5S_t *space) HDassert(space); /* Call the selection type's serial_size function */ - ret_value=(*space->select.type->serial_size)(space); + ret_value = (*space->select.type->serial_size)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_serial_size() */ +} /* end H5S_select_serial_size() */ /*-------------------------------------------------------------------------- @@ -311,7 +391,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 @@ -319,10 +399,10 @@ H5S_select_serialize(const H5S_t *space, uint8_t **p) HDassert(p); /* Call the selection type's serialize function */ - ret_value=(*space->select.type->serialize)(space,p); + ret_value = (*space->select.type->serialize)(space, p); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_serialize() */ +} /* end H5S_select_serialize() */ /*-------------------------------------------------------------------------- @@ -359,7 +439,7 @@ H5Sget_select_npoints(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_npoints() */ +} /* H5Sget_select_npoints() */ /*-------------------------------------------------------------------------- @@ -382,7 +462,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -hssize_t +H5_ATTR_PURE hssize_t H5S_get_select_npoints(const H5S_t *space) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -391,7 +471,7 @@ H5S_get_select_npoints(const H5S_t *space) HDassert(space); FUNC_LEAVE_NOAPI((hssize_t)space->select.num_elem) -} /* H5S_get_select_npoints() */ +} /* end H5S_get_select_npoints() */ /*-------------------------------------------------------------------------- @@ -413,8 +493,6 @@ H5S_get_select_npoints(const H5S_t *space) COMMENTS, BUGS, ASSUMPTIONS EXAMPLES REVISION LOG - Christian Chilan 01/17/2007 - Changed the error return value from 0 to FAIL. --------------------------------------------------------------------------*/ htri_t H5Sselect_valid(hid_t spaceid) @@ -433,7 +511,7 @@ H5Sselect_valid(hid_t spaceid) done: FUNC_LEAVE_API(ret_value) -} /* H5Sselect_valid() */ +} /* end H5Sselect_valid() */ /*-------------------------------------------------------------------------- @@ -471,7 +549,7 @@ H5S_select_valid(const H5S_t *space) ret_value = (*space->select.type->is_valid)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_valid() */ +} /* end H5S_select_valid() */ /*-------------------------------------------------------------------------- @@ -584,7 +662,7 @@ H5S_select_deserialize(H5S_t **space, const uint8_t **p) default: break; - } + } /* end switch */ if(ret_value < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTLOAD, FAIL, "can't deserialize selection") @@ -599,7 +677,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_deserialize() */ +} /* end H5S_select_deserialize() */ /*-------------------------------------------------------------------------- @@ -651,7 +729,7 @@ H5Sget_select_bounds(hid_t spaceid, hsize_t start[], hsize_t end[]) done: FUNC_LEAVE_API(ret_value) -} /* H5Sget_select_bounds() */ +} /* end H5Sget_select_bounds() */ /*-------------------------------------------------------------------------- @@ -693,10 +771,10 @@ H5S_get_select_bounds(const H5S_t *space, hsize_t *start, hsize_t *end) HDassert(start); HDassert(end); - ret_value = (*space->select.type->bounds)(space,start,end); + ret_value = (*space->select.type->bounds)(space, start, end); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_bounds() */ +} /* end H5S_get_select_bounds() */ /*-------------------------------------------------------------------------- @@ -736,7 +814,7 @@ H5S_get_select_offset(const H5S_t *space, hsize_t *offset) ret_value = (*space->select.type->offset)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_offset() */ +} /* end H5S_get_select_offset() */ /*-------------------------------------------------------------------------- @@ -774,7 +852,7 @@ H5S_get_select_unlim_dim(const H5S_t *space) ret_value = (*space->select.type->unlim_dim)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_unlim_dim() */ +} /* end H5S_get_select_unlim_dim() */ /*-------------------------------------------------------------------------- @@ -819,7 +897,7 @@ H5S_get_select_num_elem_non_unlim(const H5S_t *space, done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_select_unlim_dim() */ +} /* end H5S_get_select_unlim_dim() */ /*-------------------------------------------------------------------------- @@ -856,7 +934,7 @@ H5S_select_is_contiguous(const H5S_t *space) ret_value = (*space->select.type->is_contiguous)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_contiguous() */ +} /* end H5S_select_is_contiguous() */ /*-------------------------------------------------------------------------- @@ -893,7 +971,7 @@ H5S_select_is_single(const H5S_t *space) ret_value = (*space->select.type->is_single)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_single() */ +} /* end H5S_select_is_single() */ /*-------------------------------------------------------------------------- @@ -930,7 +1008,7 @@ H5S_select_is_regular(const H5S_t *space) ret_value = (*space->select.type->is_regular)(space); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_is_regular() */ +} /* end H5S_select_is_regular() */ /*-------------------------------------------------------------------------- @@ -968,7 +1046,7 @@ H5S_select_adjust_u(H5S_t *space, const hsize_t *offset) ret_value = (*space->select.type->adjust_u)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_adjust_u() */ +} /* end H5S_select_adjust_u() */ /*-------------------------------------------------------------------------- @@ -1007,7 +1085,7 @@ H5S_select_project_scalar(const H5S_t *space, hsize_t *offset) ret_value = (*space->select.type->project_scalar)(space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_scalar() */ +} /* end H5S_select_project_scalar() */ /*-------------------------------------------------------------------------- @@ -1048,7 +1126,7 @@ H5S_select_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset) ret_value = (*space->select.type->project_simple)(space, new_space, offset); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_simple() */ +} /* end H5S_select_project_simple() */ /*-------------------------------------------------------------------------- @@ -1098,7 +1176,7 @@ H5S_select_iter_init(H5S_sel_iter_t *sel_iter, const H5S_t *space, size_t elmt_s HDassert(sel_iter->type); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_init() */ +} /* end H5S_select_iter_init() */ /*-------------------------------------------------------------------------- @@ -1135,10 +1213,10 @@ H5S_select_iter_coords(const H5S_sel_iter_t *sel_iter, hsize_t *coords) HDassert(coords); /* Call iter_coords routine for selection type */ - ret_value = (*sel_iter->type->iter_coords)(sel_iter,coords); + ret_value = (*sel_iter->type->iter_coords)(sel_iter, coords); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_coords() */ +} /* end H5S_select_iter_coords() */ #ifdef LATER @@ -1170,7 +1248,7 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) { herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); @@ -1178,10 +1256,10 @@ H5S_select_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end) HDassert(end); /* Call iter_block routine for selection type */ - ret_value = (*iter->type->iter_block)(iter,start,end); + ret_value = (*iter->type->iter_block)(iter, start, end); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_block() */ +} /* end H5S_select_iter_block() */ #endif /* LATER */ @@ -1219,7 +1297,7 @@ H5S_select_iter_nelmts(const H5S_sel_iter_t *sel_iter) ret_value = (*sel_iter->type->iter_nelmts)(sel_iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_nelmts() */ +} /* end H5S_select_iter_nelmts() */ #ifdef LATER @@ -1249,7 +1327,7 @@ H5S_select_iter_has_next_block(const H5S_sel_iter_t *iter) { herr_t ret_value; /* return value */ - FUNC_ENTER_NOAPI_NOINIT_NOINIT_NOERR + FUNC_ENTER_NOAPI_NOINIT_NOERR /* Check args */ HDassert(iter); @@ -1258,7 +1336,7 @@ 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) -} /* H5S_select_iter_has_next_block() */ +} /* end H5S_select_iter_has_next_block() */ #endif /* LATER */ @@ -1296,13 +1374,13 @@ H5S_select_iter_next(H5S_sel_iter_t *iter, size_t nelem) HDassert(nelem>0); /* Call iter_next routine for selection type */ - ret_value = (*iter->type->iter_next)(iter,nelem); + ret_value = (*iter->type->iter_next)(iter, nelem); /* Decrement the number of elements left in selection */ iter->elmt_left-=nelem; FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_next() */ +} /* end H5S_select_iter_next() */ #ifdef LATER @@ -1343,7 +1421,7 @@ H5S_select_iter_next_block(H5S_sel_iter_t *iter) ret_value = (*iter->type->iter_next_block)(iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_next_block() */ +} /* end H5S_select_iter_next_block() */ #endif /* LATER */ @@ -1381,7 +1459,7 @@ H5S_select_iter_release(H5S_sel_iter_t *sel_iter) ret_value = (*sel_iter->type->iter_release)(sel_iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_iter_release() */ +} /* end H5S_select_iter_release() */ /*-------------------------------------------------------------------------- @@ -1421,7 +1499,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, 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[H5O_LAYOUT_NDIMS]; /* Dataspace size */ + 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 */ @@ -1495,7 +1573,7 @@ H5S_select_iterate(void *buf, const H5T_t *type, const H5S_t *space, /* Loop, while bytes left in sequence */ while(curr_len > 0 && user_ret == 0) { - hsize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of element in dataspace */ + 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 */ @@ -1558,7 +1636,7 @@ done: iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_select_iterate() */ +} /* end H5S_select_iterate() */ /*-------------------------------------------------------------------------- @@ -1594,7 +1672,7 @@ H5Sget_select_type(hid_t space_id) done: FUNC_LEAVE_API(ret_value) -} /* end H5Sget_select_type() */ +} /* end H5Sget_select_type() */ /*-------------------------------------------------------------------------- @@ -1616,7 +1694,7 @@ done: pattern, don't call it directly, use the appropriate macro defined in H5Sprivate.h. --------------------------------------------------------------------------*/ -H5S_sel_type +H5_ATTR_PURE H5S_sel_type H5S_get_select_type(const H5S_t *space) { H5S_sel_type ret_value = H5S_SEL_ERROR; /* Return value */ @@ -1627,10 +1705,10 @@ H5S_get_select_type(const H5S_t *space) HDassert(space); /* Set return value */ - ret_value=H5S_GET_SELECT_TYPE(space); + ret_value = H5S_GET_SELECT_TYPE(space); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5S_get_select_type() */ +} /* end H5S_get_select_type() */ /*-------------------------------------------------------------------------- @@ -1661,9 +1739,9 @@ 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 */ + 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) @@ -1683,20 +1761,19 @@ H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2) unsigned space_a_rank; /* Number of dimensions of dataspace A */ unsigned space_b_rank; /* Number of dimensions of dataspace B */ - /* need to be able to handle spaces of different rank: + /* Need to be able to handle spaces of different rank: * * To simplify logic, let space_a point to the element of the set - * {space1, space2} with the largest rank or space1 if the ranks + * {space1, space2} with the largest rank or space1 if the ranks * are identical. * * Similarly, let space_b point to the element of {space1, space2} * with the smallest rank, or space2 if they are identical. * - * Let: space_a_rank be the rank of space_a, + * Let: space_a_rank be the rank of space_a, * space_b_rank be the rank of space_b, - * delta_rank = space_a_rank - space_b_rank. * - * Set all this up below. + * Set all this up here. */ if(space1->extent.rank >= space2->extent.rank) { space_a = space1; @@ -1934,7 +2011,7 @@ done: iter_b = H5FL_FREE(H5S_sel_iter_t, iter_b); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_shape_same() */ +} /* end H5S_select_shape_same() */ /*-------------------------------------------------------------------------- @@ -1943,24 +2020,24 @@ done: PURPOSE Given a dataspace a of rank n with some selection, construct a new - dataspace b of rank m (m != n), with the selection in a being - topologically identical to that in b (as verified by + dataspace b of rank m (m != n), with the selection in a being + topologically identical to that in b (as verified by H5S_select_shape_same(). - This function exists, as some I/O code chokes on topologically - identical selections with different ranks. At least to begin + This function exists, as some I/O code chokes on topologically + identical selections with different ranks. At least to begin with, we will deal with the issue by constructing projections - of the memory dataspace with ranks equaling those of the file + of the memory dataspace with ranks equaling those of the file dataspace. - Note that if m > n, it is possible that the starting point in the - buffer associated with the memory dataspace will have to be + Note that if m > n, it is possible that the starting point in the + buffer associated with the memory dataspace will have to be adjusted to match the projected dataspace. If the buf parameter is not NULL, the function must return an adjusted buffer base address in *adj_buf_ptr. USAGE - htri_t H5S_select_construct_projection(base_space, + htri_t H5S_select_construct_projection(base_space, new_space_ptr, new_space_rank, buf, @@ -1969,30 +2046,30 @@ done: H5S_t ** new_space_ptr; OUT: Ptr to location in which to return the address of the projected space int new_space_rank; IN: Rank of the projected space. - const void * buf; IN: Base address of the buffer + const void * buf; IN: Base address of the buffer associated with the base space. May be NULL. void ** adj_buf_ptr; OUT: If buf != NULL, store the base - address of the section of buf + 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. DESCRIPTION - Construct a new dataspace and associated selection which is a - projection of the supplied dataspace and associated selection into + Construct a new dataspace and associated selection which is a + projection of the supplied dataspace and associated selection into the specified rank. Return it in *new_space_ptr. - If buf is supplied, computes the base address of the projected + If buf is supplied, computes the base address of the projected selection in buf, and stores the base address in *adj_buf_ptr. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS - The selection in the supplied base_space has thickness 1 in all + The selection in the supplied base_space has thickness 1 in all dimensions greater than new_space_rank. Note that here we count - dimensions from the fastest changing coordinate to the slowest + dimensions from the fastest changing coordinate to the slowest changing changing coordinate. EXAMPLES REVISION LOG @@ -2038,28 +2115,28 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, /* Create new scalar dataspace */ 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 * we will just be discarding it shortly. */ - /* Selection for the new space will be either all or + /* Selection for the new space will be either all or * none, depending on whether the base space has 0 or * 1 elements selected. * - * Observe that the base space can't have more than + * Observe that the base space can't have more than * one selected element, since its selection has the - * same shape as the file dataspace, and that data + * same shape as the file dataspace, and that data * space is scalar. */ if(1 == npoints) { /* Assuming that the selection in the base dataspace is not - * empty, we must compute the offset of the selected item in + * empty, we must compute the offset of the selected item in * the buffer associated with the base dataspace. * - * Since the new space rank is zero, we know that the - * the base space must have rank at least 1 -- and - * hence it is a simple dataspace. However, the + * Since the new space rank is zero, we know that the + * the base space must have rank at least 1 -- and + * hence it is a simple dataspace. However, the * selection, may be either point, hyperspace, or all. * */ @@ -2077,25 +2154,25 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, 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. * - * How we do this depends on whether we are projecting up into - * increased dimensions, or down into a reduced number of + * How we do this depends on whether we are projecting up into + * increased dimensions, or down into a reduced number of * dimensions. * - * If we are projecting up (the first half of the following - * if statement), we copy the dimensions of the base data - * space into the fastest changing dimensions of the new + * If we are projecting up (the first half of the following + * if statement), we copy the dimensions of the base data + * space into the fastest changing dimensions of the new * projected dataspace, and set the remaining dimensions to * one. * * If we are projecting down (the second half of the following - * if statement), we just copy the dimensions with the most + * if statement), we just copy the dimensions with the most * quickly changing dimensions into the dims for the projected * data set. * - * This works, because H5S_select_shape_same() will return + * This works, because H5S_select_shape_same() will return * true on selections of different rank iff: * * 1) the selection in the lower rank dataspace matches that @@ -2103,13 +2180,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * the larger rank dataspace, and * * 2) the selection has thickness 1 in all ranks that appear - * only in the higher rank dataspace (i.e. those with + * 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 */ - /* we must copy the dimensions of the base space into + /* we must copy the dimensions of the base space into * the fastest changing dimensions of the new space, * and set the remaining dimensions to 1 */ @@ -2120,7 +2197,7 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, HDmemcpy(&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 + /* 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; @@ -2128,12 +2205,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, HDmemcpy(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 -- + /* 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))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create simple dataspace") - + /* No need to register the dataspace(i.e. get an ID) as * we will just be discarding it shortly. */ @@ -2144,13 +2221,13 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, */ 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 * the selection in the base dataspace into the new dataspace. * - * If the base dataspace is simple, check to see if the - * offset_changed flag on the base selection has been set -- if so, - * project the offset into the new dataspace and set the + * If the base dataspace is simple, check to see if the + * offset_changed flag on the base selection has been set -- if so, + * 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) { @@ -2182,12 +2259,12 @@ H5S_select_construct_projection(const H5S_t *base_space, H5S_t **new_space_ptr, * Since we can't do pointer arithmetic on void pointers, we first * cast buf to a pointer to byte -- i.e. uint8_t. * - * We then multiply the projected space element offset we - * calculated earlier by the supplied element size, add this - * value to the type cast buf pointer, cast the result back + * We then multiply the projected space element offset we + * calculated earlier by the supplied element size, add this + * value to the type cast buf pointer, cast the result back * to a pointer to void, and assign the result to *adj_buf_ptr. */ - *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + + *adj_buf_ptr = (const void *)(((const uint8_t *)buf) + ((size_t)(projected_space_element_offset * element_size))); } /* end if */ else @@ -2202,7 +2279,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_construct_projection() */ +} /* end H5S_select_construct_projection() */ /*-------------------------------------------------------------------------- @@ -2233,7 +2310,7 @@ 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 = 0; /* Selection iteration info has been initialized */ + 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 */ @@ -2255,7 +2332,7 @@ H5S_select_fill(const void *fill, size_t fill_size, const H5S_t *space, void *_b /* Initialize iterator */ if(H5S_select_iter_init(iter, space, fill_size) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to initialize selection iterator") - iter_init = 1; /* 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) @@ -2310,7 +2387,7 @@ done: iter = H5FL_FREE(H5S_sel_iter_t, iter); FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_fill() */ +} /* end H5S_select_fill() */ /*-------------------------------------------------------------------------- @@ -2337,7 +2414,7 @@ done: 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 new_space_ptr. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -2361,7 +2438,7 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, /* Create new space, using dst extent. Start with "all" selection. */ 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 @@ -2379,14 +2456,14 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space, if(H5S_select_none(new_space) < 0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection") } /* end if */ - /* If any of the spaces use point selection, fall back to general algorithm - */ + /* If any of the spaces use point selection, fall back to general algorithm */ else if((src_intersect_space->select.type->type == H5S_SEL_POINTS) || (src_space->select.type->type == H5S_SEL_POINTS) || (dst_space->select.type->type == H5S_SEL_POINTS)) HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported") else { HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS); + /* Intersecting space is hyperslab selection. Call the hyperslab * routine to project to another hyperslab selection. */ if(H5S__hyper_project_intersection(src_space, dst_space, src_intersect_space, new_space) < 0) @@ -2403,7 +2480,7 @@ done: HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_project_intersection() */ +} /* end H5S_select_project_intersection() */ /*-------------------------------------------------------------------------- @@ -2425,7 +2502,7 @@ done: Removes any and all portions of space that are also present in subtract_space. In essence, performs an A_NOT_B operation with the two selections. - + GLOBAL VARIABLES COMMENTS, BUGS, ASSUMPTIONS EXAMPLES @@ -2493,5 +2570,5 @@ H5S_select_subtract(H5S_t *space, H5S_t *subtract_space) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_subtract() */ +} /* end H5S_select_subtract() */ diff --git a/src/H5Stest.c b/src/H5Stest.c index a7bee2b..50f5fa9 100644 --- a/src/H5Stest.c +++ b/src/H5Stest.c @@ -17,23 +17,60 @@ * Purpose: Dataspace selection testing functions. */ +/****************/ +/* Module Setup */ +/****************/ + #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 */ +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + /*-------------------------------------------------------------------------- NAME - H5S_select_shape_same_test + H5S__select_shape_same_test PURPOSE Determine if two dataspace selections are the same shape USAGE - htri_t H5S_select_shape_same_test(sid1, sid2) + htri_t H5S__select_shape_same_test(sid1, sid2) hid_t sid1; IN: 1st dataspace to compare hid_t sid2; IN: 2nd dataspace to compare RETURNS @@ -48,13 +85,13 @@ REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S_select_shape_same_test(hid_t sid1, hid_t sid2) +H5S__select_shape_same_test(hid_t sid1, hid_t sid2) { H5S_t *space1; /* Pointer to 1st dataspace */ H5S_t *space2; /* Pointer to 2nd dataspace */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Get dataspace structures */ if(NULL == (space1 = (H5S_t *)H5I_object_verify(sid1, H5I_DATASPACE))) @@ -68,16 +105,16 @@ H5S_select_shape_same_test(hid_t sid1, hid_t sid2) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_select_shape_same_test() */ +} /* H5S__select_shape_same_test() */ /*-------------------------------------------------------------------------- NAME - H5S_get_rebuild_status_test + H5S__get_rebuild_status_test PURPOSE Determine the status of hyperslab rebuild USAGE - htri_t H5S_inquiry_rebuild_status(hid_t space_id) + htri_t H5S__get_rebuild_status_test(hid_t space_id) hid_t space_id; IN: dataspace id RETURNS Non-negative TRUE/FALSE on success, negative on failure @@ -90,12 +127,12 @@ done: REVISION LOG --------------------------------------------------------------------------*/ htri_t -H5S_get_rebuild_status_test(hid_t space_id) +H5S__get_rebuild_status_test(hid_t space_id) { H5S_t *space; /* Pointer to 1st dataspace */ htri_t ret_value = FAIL; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE /* Get dataspace structures */ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) @@ -105,5 +142,5 @@ H5S_get_rebuild_status_test(hid_t space_id) done: FUNC_LEAVE_NOAPI(ret_value) -} /* H5S_get_rebuild_status_test() */ +} /* H5S__get_rebuild_status_test() */ diff --git a/test/objcopy.c b/test/objcopy.c index eb4927f..4055781 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -1167,7 +1167,7 @@ compare_data(hid_t parent1, hid_t parent2, hid_t pid, hid_t tid, size_t nelmts, if((obj2_sid = H5Rget_region(parent2, H5R_DATASET_REGION, ref_buf2)) < 0) TEST_ERROR /* Check if dataspaces are the same shape */ - if(H5S_select_shape_same_test(obj1_sid, obj2_sid) < 0) TEST_ERROR + if(H5S__select_shape_same_test(obj1_sid, obj2_sid) < 0) TEST_ERROR /* Close dataspaces */ if(H5Sclose(obj1_sid) < 0) TEST_ERROR @@ -2136,9 +2136,7 @@ test_copy_dataset_versionbounds(hid_t fcpl_src, hid_t fapl_src) char src_fname[NAME_BUF_SIZE]; /* Name of source file */ char dst_fname[NAME_BUF_SIZE]; /* Name of destination file */ H5F_libver_t low, high; /* File format bounds */ - H5F_libver_t low_src, high_src; /* Source file format bounds */ unsigned srcdset_fillversion; /* Fill version of source dataset */ - hbool_t valid_high = FALSE; /* TRUE if high bound is valid */ int i, j; /* Local index variables */ H5D_t *dsetp = NULL; /* Pointer to internal dset structure */ herr_t ret; /* Generic return value */ diff --git a/test/tselect.c b/test/tselect.c index bcc2a5b..9150b11 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -1888,9 +1888,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(small_cube_sid, + check = H5S__select_shape_same_test(small_cube_sid, file_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Read selection from disk */ ret = H5Dread(large_cube_dataset, @@ -1965,9 +1965,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(small_cube_sid, + check = H5S__select_shape_same_test(small_cube_sid, mem_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Read selection from disk */ @@ -2082,9 +2082,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, * memory slice through the cube selection and the * on disk full small cube selections as having the same shape. */ - check = H5S_select_shape_same_test(small_cube_sid, + check = H5S__select_shape_same_test(small_cube_sid, mem_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* write the slice from the in memory large cube to the on disk small cube */ @@ -2193,9 +2193,9 @@ test_select_hyper_contig_dr__run_test(int test_num, const uint16_t *cube_buf, * on disk slice through the large cube selection * as having the same shape. */ - check = H5S_select_shape_same_test(small_cube_sid, + check = H5S__select_shape_same_test(small_cube_sid, file_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* write the cube from memory to the target slice of the disk cube */ @@ -2998,9 +2998,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(mem_small_cube_sid, + check = H5S__select_shape_same_test(mem_small_cube_sid, file_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* zero the buffer that we will be using for reading */ HDmemset(small_cube_buf_1, 0, sizeof(*small_cube_buf_1) * small_cube_size); @@ -3105,9 +3105,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(file_small_cube_sid, + check = H5S__select_shape_same_test(file_small_cube_sid, mem_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* zero out the in memory large cube */ @@ -3258,9 +3258,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(file_small_cube_sid, + check = H5S__select_shape_same_test(file_small_cube_sid, mem_large_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* write the slice from the in memory large cube to the @@ -3390,9 +3390,9 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(file_large_cube_sid, + check = H5S__select_shape_same_test(file_large_cube_sid, mem_small_cube_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* write the checker board selection of the in memory @@ -3525,13 +3525,13 @@ test_select_hyper_checker_board_dr__run_test(int test_num, const uint16_t *cube_ /**************************************************************** ** -** test_select_hyper_checker_board_dr(): Test H5S (dataspace) -** selection code with checkerboard source and target having +** test_select_hyper_checker_board_dr(): Test H5S (dataspace) +** selection code with checkerboard source and target having ** different ranks but the same shape. We have already -** tested H5S_shape_same in isolation, so now we try to do +** tested H5S_shape_same in isolation, so now we try to do ** I/O. ** -** This is just an initial smoke check, so we will work +** This is just an initial smoke check, so we will work ** with a slice through a cube only. ** ****************************************************************/ @@ -5902,6 +5902,10 @@ test_select_hyper_union_random_5d(hid_t read_plist) /* Select hyperslab */ ret = H5Sselect_hyperslab(sid1, (i == 0 ? H5S_SELECT_SET : H5S_SELECT_OR), start, NULL, count, NULL); CHECK(ret, FAIL, "H5Sselect_hyperslab"); + if(ret < 0) { + TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); + break; + } /* end if */ } /* end for */ /* Get the number of elements selected */ @@ -5920,14 +5924,18 @@ test_select_hyper_union_random_5d(hid_t read_plist) /* Read selection from disk */ ret=H5Dread(dataset,H5T_NATIVE_INT,sid2,sid1,read_plist,rbuf); CHECK(ret, FAIL, "H5Dread"); + if(ret < 0) { + TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); + break; + } /* end if */ /* Compare data read with data written out */ tbuf=rbuf; ret = H5Diterate(wbuf,H5T_NATIVE_INT,sid1,test_select_hyper_iter2,&tbuf); - if(ret<0) { - TestErrPrintf("Random hyperslabs for seed %u failed!\n",seed); + if(ret < 0) { + TestErrPrintf("Random hyperslabs for seed %u failed!\n", seed); break; - } + } /* end if */ /* Set the read buffer back to all zeroes */ HDmemset(rbuf, 0, (size_t)SPACE6_DIM1); @@ -6585,7 +6593,7 @@ test_select_combine(void) hsize_t dims[SPACE7_RANK]={SPACE7_DIM1,SPACE7_DIM2}; /* Dimensions of dataspace */ H5S_sel_type sel_type; /* Selection type */ hssize_t nblocks; /* Number of hyperslab blocks */ - hsize_t blocks[128][2][SPACE7_RANK]; /* List of blocks */ + hsize_t blocks[16][2][SPACE7_RANK]; /* List of blocks */ herr_t error; /* Output message about test being performed */ @@ -8087,290 +8095,290 @@ test_shape_same(void) /* Compare "all" selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(all_sid,all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(all_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(all_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(all_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,single_hyper_all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,single_hyper_all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(all_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(all_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare "none" selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(none_sid,none_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,none_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(none_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(none_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(none_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(none_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(none_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(none_sid,none_hyper_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid,none_hyper_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(none_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(none_sid, scalar_none_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(none_sid, scalar_none_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare single point selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(single_pt_sid,single_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,single_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(single_pt_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(single_pt_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(single_pt_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(single_pt_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(single_pt_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,single_hyper_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,single_hyper_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(single_pt_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(single_pt_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(single_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare multiple point selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(mult_pt_sid,mult_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,mult_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(mult_pt_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(mult_pt_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(mult_pt_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(mult_pt_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(mult_pt_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(mult_pt_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(mult_pt_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(mult_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(mult_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare single "normal" hyperslab selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(single_hyper_sid,single_hyper_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(single_hyper_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(single_hyper_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(single_hyper_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(single_hyper_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(single_hyper_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); #ifdef NOT_YET /* In theory, these two selections are the same shape, but the @@ -8394,8 +8402,8 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -8421,70 +8429,70 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare single "all" hyperslab selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(single_hyper_all_sid,single_hyper_all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(single_hyper_all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(single_hyper_all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); #ifdef NOT_YET /* In theory, these two selections are the same shape, but the @@ -8508,8 +8516,8 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -8535,129 +8543,129 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_all_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_all_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare single "point" hyperslab selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,single_hyper_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,single_hyper_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(single_hyper_pt_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(single_hyper_pt_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,single_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,single_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(single_hyper_pt_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_pt_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(single_hyper_pt_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(single_hyper_pt_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare regular, strided hyperslab selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(regular_hyper_sid,regular_hyper_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,regular_hyper_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(regular_hyper_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(regular_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Construct point selection which matches regular, strided hyperslab selection */ /* Create dataspace for point selection */ @@ -8674,8 +8682,8 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -8700,8 +8708,8 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); @@ -8720,70 +8728,70 @@ test_shape_same(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(regular_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(regular_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(regular_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(regular_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare irregular hyperslab selection to all the selections created */ /* Compare against itself */ - check=H5S_select_shape_same_test(irreg_hyper_sid,irreg_hyper_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,irreg_hyper_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid=H5Scopy(irreg_hyper_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check=H5S_select_shape_same_test(irreg_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Construct hyperslab selection which matches irregular hyperslab selection */ /* Create dataspace for hyperslab selection */ @@ -8808,141 +8816,141 @@ test_shape_same(void) } /* end for */ /* Compare against hyperslab selection */ - check=H5S_select_shape_same_test(irreg_hyper_sid,tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid,tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(irreg_hyper_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(irreg_hyper_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(irreg_hyper_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare scalar "all" dataspace with all selections created */ /* Compare against itself */ - check = H5S_select_shape_same_test(scalar_all_sid, scalar_all_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, scalar_all_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid = H5Scopy(scalar_all_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S_select_shape_same_test(scalar_all_sid, tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S_select_shape_same_test(scalar_all_sid, all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check = H5S_select_shape_same_test(scalar_all_sid, none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check = H5S_select_shape_same_test(scalar_all_sid, single_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, single_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check = H5S_select_shape_same_test(scalar_all_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, single_hyper_pt_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, single_hyper_pt_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, none_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, none_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against scalar "none" hyperslab selection */ - check = H5S_select_shape_same_test(scalar_all_sid, scalar_none_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_all_sid, scalar_none_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare scalar "none" dataspace with all selections created */ /* Compare against itself */ - check = H5S_select_shape_same_test(scalar_none_sid, scalar_none_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, scalar_none_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against copy of itself */ tmp_sid = H5Scopy(scalar_none_sid); CHECK(tmp_sid, FAIL, "H5Scopy"); - check = H5S_select_shape_same_test(scalar_none_sid, tmp_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, tmp_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); ret = H5Sclose(tmp_sid); CHECK(ret, FAIL, "H5Sclose"); /* Compare against "all" selection */ - check = H5S_select_shape_same_test(scalar_none_sid, all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "none" selection */ - check = H5S_select_shape_same_test(scalar_none_sid, none_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, none_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against single point selection */ - check = H5S_select_shape_same_test(scalar_none_sid, single_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, single_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against multiple point selection */ - check = H5S_select_shape_same_test(scalar_none_sid, mult_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, mult_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "plain" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, single_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, single_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "all" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, single_hyper_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, single_hyper_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "single point" single hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, single_hyper_pt_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, single_hyper_pt_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against regular, strided hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, regular_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, regular_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against irregular hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, irreg_hyper_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, irreg_hyper_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "no" hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, none_hyper_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, none_hyper_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Compare against scalar "all" hyperslab selection */ - check = H5S_select_shape_same_test(scalar_none_sid, scalar_all_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(scalar_none_sid, scalar_all_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Close dataspaces */ @@ -8974,27 +8982,27 @@ test_shape_same(void) /**************************************************************** ** -** test_shape_same_dr__smoke_check_1(): +** test_shape_same_dr__smoke_check_1(): ** -** Create a square, 2 D data space (10 X 10), and select +** Create a square, 2 D data space (10 X 10), and select ** all of it. ** -** Similarly, create nine, 3 D data spaces (10 X 10 X 10), -** and select (10 X 10 X 1) hyper slabs in each, three with -** the slab parallel to the xy plane, three parallel to the +** Similarly, create nine, 3 D data spaces (10 X 10 X 10), +** and select (10 X 10 X 1) hyper slabs in each, three with +** the slab parallel to the xy plane, three parallel to the ** xz plane, and three parallel to the yz plane. ** -** Assuming that z is the fastest changing dimension, -** H5S_select_shape_same() should return TRUE when comparing -** the full 2 D space against any hyperslab parallel to the -** yz plane in the 3 D space, and FALSE when comparing the +** Assuming that z is the fastest changing dimension, +** H5S_select_shape_same() should return TRUE when comparing +** the full 2 D space against any hyperslab parallel to the +** yz plane in the 3 D space, and FALSE when comparing the ** full 2 D space against the other two hyper slabs. ** -** Also create two additional 3 D data spaces (10 X 10 X 10), -** and select a (10 X 10 X 2) hyper slab parallel to the yz -** axis in one of them, and two parallel (10 X 10 X 1) hyper -** slabs parallel to the yz axis in the other. -** H5S_select_shape_same() should return FALSE when comparing +** Also create two additional 3 D data spaces (10 X 10 X 10), +** and select a (10 X 10 X 2) hyper slab parallel to the yz +** axis in one of them, and two parallel (10 X 10 X 1) hyper +** slabs parallel to the yz axis in the other. +** H5S_select_shape_same() should return FALSE when comparing ** each to the 2 D selection. ** ****************************************************************/ @@ -9183,42 +9191,42 @@ test_shape_same_dr__smoke_check_1(void) /* setup is done -- run the tests: */ /* Compare against "xy" selection */ - check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "xz" selection */ - check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "yz" selection */ - check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_4_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_4_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Close dataspaces */ @@ -9265,9 +9273,9 @@ test_shape_same_dr__smoke_check_1(void) /**************************************************************** ** -** test_shape_same_dr__smoke_check_2(): +** test_shape_same_dr__smoke_check_2(): ** -** Create a square, 2 D data space (10 X 10), and select +** Create a square, 2 D data space (10 X 10), and select ** a "checker board" hyper slab as follows: ** ** * * - - * * - - * * @@ -9281,27 +9289,27 @@ test_shape_same_dr__smoke_check_1(void) ** * * - - * * - - * * ** * * - - * * - - * * ** -** where asterisks indicate selected elements, and dashes +** where asterisks indicate selected elements, and dashes ** indicate unselected elements. ** -** Similarly, create nine, 3 D data spaces (10 X 10 X 10), -** and select similar (10 X 10 X 1) checker board hyper -** slabs in each, three with the slab parallel to the xy -** plane, three parallel to the xz plane, and three parallel +** Similarly, create nine, 3 D data spaces (10 X 10 X 10), +** and select similar (10 X 10 X 1) checker board hyper +** slabs in each, three with the slab parallel to the xy +** plane, three parallel to the xz plane, and three parallel ** to the yz plane. ** -** Assuming that z is the fastest changing dimension, -** H5S_select_shape_same() should return TRUE when comparing -** the 2 D space checker board selection against a checker -** board hyperslab parallel to the yz plane in the 3 D -** space, and FALSE when comparing the 2 D checkerboard -** selection against two hyper slabs parallel to the xy +** Assuming that z is the fastest changing dimension, +** H5S_select_shape_same() should return TRUE when comparing +** the 2 D space checker board selection against a checker +** board hyperslab parallel to the yz plane in the 3 D +** space, and FALSE when comparing the 2 D checkerboard +** selection against two hyper slabs parallel to the xy ** or xz planes. ** -** Also create an additional 3 D data spaces (10 X 10 X 10), -** and select a checker board parallel with the yz axis, -** save with some squares being on different planes. -** H5S_select_shape_same() should return FALSE when +** Also create an additional 3 D data spaces (10 X 10 X 10), +** and select a checker board parallel with the yz axis, +** save with some squares being on different planes. +** H5S_select_shape_same() should return FALSE when ** comparing this selection to the 2 D selection. ** ****************************************************************/ @@ -9584,7 +9592,7 @@ test_shape_same_dr__smoke_check_2(void) start[0] = 4; /* This test gets the right answer, but it fails the shape same - * test in an unexpected point. Bring this up with Quincey, as + * test in an unexpected point. Bring this up with Quincey, as * the oddness looks like it is not related to my code. * -- JRM */ @@ -9596,39 +9604,39 @@ test_shape_same_dr__smoke_check_2(void) /* setup is done -- run the tests: */ /* Compare against "xy" selection */ - check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "xz" selection */ - check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "yz" selection */ - check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_3_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Close dataspaces */ @@ -9673,9 +9681,9 @@ test_shape_same_dr__smoke_check_2(void) /**************************************************************** ** -** test_shape_same_dr__smoke_check_3(): +** test_shape_same_dr__smoke_check_3(): ** -** Create a square, 2 D data space (10 X 10), and select an +** Create a square, 2 D data space (10 X 10), and select an ** irregular hyper slab as follows: ** ** y @@ -9691,22 +9699,22 @@ test_shape_same_dr__smoke_check_2(void) ** 0 - - - - - - - - - - ** 0 1 2 3 4 5 6 7 8 9 x ** -** where asterisks indicate selected elements, and dashes +** where asterisks indicate selected elements, and dashes ** indicate unselected elements. ** -** Similarly, create nine, 3 D data spaces (10 X 10 X 10), -** and select similar irregular hyper slabs in each, three -** with the slab parallel to the xy plane, three parallel -** to the xz plane, and three parallel to the yz plane. -** Further, translate the irregular slab in 2/3rds of the +** Similarly, create nine, 3 D data spaces (10 X 10 X 10), +** and select similar irregular hyper slabs in each, three +** with the slab parallel to the xy plane, three parallel +** to the xz plane, and three parallel to the yz plane. +** Further, translate the irregular slab in 2/3rds of the ** cases. ** -** Assuming that z is the fastest changing dimension, -** H5S_select_shape_same() should return TRUE when -** comparing the 2 D irregular hyperslab selection -** against the irregular hyperslab selections parallel -** to the yz plane in the 3 D space, and FALSE when -** comparing it against the irregular hyper slabs +** Assuming that z is the fastest changing dimension, +** H5S_select_shape_same() should return TRUE when +** comparing the 2 D irregular hyperslab selection +** against the irregular hyperslab selections parallel +** to the yz plane in the 3 D space, and FALSE when +** comparing it against the irregular hyper slabs ** selections parallel to the xy or xz planes. ** ****************************************************************/ @@ -10119,36 +10127,36 @@ test_shape_same_dr__smoke_check_3(void) /* setup is done -- run the tests: */ /* Compare against "xy" selection */ - check = H5S_select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xy_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "xz" selection */ - check = H5S_select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_0_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_1_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_xz_slice_2_sid, small_square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Compare against "yz" selection */ - check = H5S_select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_0_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_1_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(small_cube_yz_slice_2_sid, small_square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); /* Close dataspaces */ @@ -10190,9 +10198,9 @@ test_shape_same_dr__smoke_check_3(void) /**************************************************************** ** -** test_shape_same_dr__smoke_check_4(): +** test_shape_same_dr__smoke_check_4(): ** -** Create a square, 2 D data space (10 X 10), and select +** Create a square, 2 D data space (10 X 10), and select ** the entire space. ** ** Similarly, create 3 D and 4 D data spaces: @@ -10213,7 +10221,7 @@ test_shape_same_dr__smoke_check_3(void) ** And select these entire spaces as well. ** ** Compare the 2 D space against all the other spaces -** with H5S_select_shape_same(). The (1 X 10 X 10) & +** with H5S_select_shape_same(). The (1 X 10 X 10) & ** (1 X 1 X 10 X 10) should return TRUE. All others ** should return FALSE. ** @@ -10331,39 +10339,39 @@ test_shape_same_dr__smoke_check_4(void) /* setup is done -- run the tests: */ - check = H5S_select_shape_same_test(three_d_space_0_sid, square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(three_d_space_0_sid, square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(three_d_space_1_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(three_d_space_1_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(three_d_space_2_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(three_d_space_2_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(three_d_space_3_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(three_d_space_3_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_0_sid, square_sid); - VERIFY(check, TRUE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_0_sid, square_sid); + VERIFY(check, TRUE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_1_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_1_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_2_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_2_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_3_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_3_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_4_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_4_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_5_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_5_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); - check = H5S_select_shape_same_test(four_d_space_6_sid, square_sid); - VERIFY(check, FALSE, "H5S_select_shape_same_test"); + check = H5S__select_shape_same_test(four_d_space_6_sid, square_sid); + VERIFY(check, FALSE, "H5S__select_shape_same_test"); /* Close dataspaces */ @@ -10410,12 +10418,12 @@ test_shape_same_dr__smoke_check_4(void) /**************************************************************** ** ** test_shape_same_dr__full_space_vs_slice(): Tests selection -** of a full n-cube data space vs an n-dimensional slice of -** of an m-cube (m > n) in a call to H5S_select_shape_same(). -** Note that this test does not require the n-cube and the +** of a full n-cube data space vs an n-dimensional slice of +** of an m-cube (m > n) in a call to H5S_select_shape_same(). +** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if -** they don't). +** H5S_select_shape_same() should always return FALSE if +** they don't). ** ** Per Quincey's suggestion, only test up to 5 dimensional ** spaces. @@ -10452,16 +10460,16 @@ test_shape_same_dr__full_space_vs_slice(int test_num, HDassert( large_rank <= SS_DR_MAX_RANK ); HDassert( 0 <= offset ); HDassert( offset < large_rank ); - HDassert( edge_size > 0 ); - HDassert( edge_size <= 1000 ); + HDassert( edge_size > 0 ); + HDassert( edge_size <= 1000 ); - sprintf(test_desc_0, - "\tn-cube slice through m-cube (n <= m) test %d.\n", + sprintf(test_desc_0, + "\tn-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - sprintf(test_desc_1, + sprintf(test_desc_1, "\t\tranks: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d.\n", small_rank, large_rank, offset, (int)dim_selected[0], @@ -10526,7 +10534,7 @@ test_shape_same_dr__full_space_vs_slice(int test_num, /* setup is done -- run the test: */ - check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid); + check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "test_shape_same_dr__full_space_vs_slice"); @@ -10542,27 +10550,27 @@ test_shape_same_dr__full_space_vs_slice(int test_num, /**************************************************************** ** -** test_shape_same_dr__run_full_space_vs_slice_tests(): +** test_shape_same_dr__run_full_space_vs_slice_tests(): ** ** Run the est_shape_same_dr__full_space_vs_slice() test ** over a variety of ranks and offsets. ** -** At present, we test H5S_select_shape_same() with +** At present, we test H5S_select_shape_same() with ** fully selected 1, 2, 3, and 4 cubes as one parameter, and ** 1, 2, 3, and 4 dimensional slices through a n-cube of rank -** no more than 5 (and at least the rank of the slice). -** We stop at rank 5, as Quincey suggested that it would be +** no more than 5 (and at least the rank of the slice). +** We stop at rank 5, as Quincey suggested that it would be ** sufficient. ** -** All the n-cubes will have lengths of the same size, so +** All the n-cubes will have lengths of the same size, so ** H5S_select_shape_same() should return true iff: ** -** 1) the rank for the fully selected n cube equals the +** 1) the rank for the fully selected n cube equals the ** number of dimensions selected in the slice through the ** m-cube (m >= n). ** ** 2) The dimensions selected in the slice through the m-cube -** are the dimesnions with the most quickly changing +** are the dimesnions with the most quickly changing ** indices. ** ****************************************************************/ @@ -10668,7 +10676,7 @@ test_shape_same_dr__run_full_space_vs_slice_tests(void) dim_selected, expected_result ); - + z++; } while((z < 2) && (large_rank >= 1)); @@ -10691,15 +10699,15 @@ test_shape_same_dr__run_full_space_vs_slice_tests(void) /**************************************************************** ** -** test_shape_same_dr__checkerboard(): Tests selection of a -** "checker board" subset of a full n-cube data space vs +** test_shape_same_dr__checkerboard(): Tests selection of a +** "checker board" subset of a full n-cube data space vs ** a "checker board" n-dimensional slice of an m-cube (m > n). -** in a call to H5S_select_shape_same(). +** in a call to H5S_select_shape_same(). ** -** Note that this test does not require the n-cube and the +** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if -** they don't). +** H5S_select_shape_same() should always return FALSE if +** they don't). ** ** Per Quincey's suggestion, only test up to 5 dimensional ** spaces. @@ -10719,11 +10727,11 @@ test_shape_same_dr__checkerboard(int test_num, char test_desc_1[128]; int i; int dims_selected = 0; - hid_t n_cube_0_sid; /* the checker board selected - * hyper cube + hid_t n_cube_0_sid; /* the checker board selected + * hyper cube */ - hid_t n_cube_1_sid; /* the hyper cube in which a - * checkerboard slice is selected + hid_t n_cube_1_sid; /* the hyper cube in which a + * checkerboard slice is selected */ hsize_t dims[SS_DR_MAX_RANK]; hsize_t base_start[2]; @@ -10745,8 +10753,8 @@ test_shape_same_dr__checkerboard(int test_num, HDassert( small_rank <= large_rank ); HDassert( large_rank <= SS_DR_MAX_RANK ); HDassert( 0 < checker_size ); - HDassert( checker_size <= edge_size ); - HDassert( edge_size <= 1000 ); + HDassert( checker_size <= edge_size ); + HDassert( edge_size <= 1000 ); HDassert( 0 <= offset ); HDassert( offset < (int)edge_size ); @@ -10757,13 +10765,13 @@ test_shape_same_dr__checkerboard(int test_num, HDassert( dims_selected >= 0 ); HDassert( dims_selected <= large_rank ); - sprintf(test_desc_0, - "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", + sprintf(test_desc_0, + "\tcheckerboard n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - sprintf(test_desc_1, + sprintf(test_desc_1, "\tranks: %d/%d edge/chkr size: %d/%d offset: %d dim_selected: %d/%d/%d/%d/%d:%d.\n", small_rank, large_rank, (int)edge_size, (int)checker_size, @@ -10803,17 +10811,17 @@ test_shape_same_dr__checkerboard(int test_num, * * * - - * * - - * * * * * - - * * - - * * * - * In both cases, asterisks indicate selected elements, + * In both cases, asterisks indicate selected elements, * and dashes indicate unselected elements. * * 3-D and 4-D ascii art is somewhat painful, so I'll * leave those selections to your imagination. :-) * * Note, that since the edge_size and checker_size are - * parameters that are passed in, the selection need + * parameters that are passed in, the selection need * not look exactly like the selection shown above. - * At present, the function allows checker sizes that - * are not even divisors of the edge size -- thus + * At present, the function allows checker sizes that + * are not even divisors of the edge size -- thus * something like the following is also possible: * * * * * - - - * * * - @@ -10827,14 +10835,14 @@ test_shape_same_dr__checkerboard(int test_num, * * * * - - - * * * - * - - - * * * - - - * * - * As the above pattern can't be selected in one + * As the above pattern can't be selected in one * call to H5Sselect_hyperslab(), and since the * values in the start, stride, count, and block - * arrays will be repeated over all entries in + * arrays will be repeated over all entries in * the selected space case, and over all selected * dimensions in the selected hyperslab case, we - * compute these values first and store them in - * in the base_start, base_stride, base_count, + * compute these values first and store them in + * in the base_start, base_stride, base_count, * and base_block arrays. */ @@ -10844,9 +10852,9 @@ test_shape_same_dr__checkerboard(int test_num, base_stride[0] = 2 * checker_size; base_stride[1] = 2 * checker_size; - /* Note that the following computation depends on the C99 - * requirement that integer division discard any fraction - * (truncation towards zero) to function correctly. As we + /* Note that the following computation depends on the C99 + * requirement that integer division discard any fraction + * (truncation towards zero) to function correctly. As we * now require C99, this shouldn't be a problem, but noting * it may save us some pain if we are ever obliged to support * pre-C99 compilers again. @@ -10863,7 +10871,7 @@ test_shape_same_dr__checkerboard(int test_num, base_block[0] = checker_size; base_block[1] = checker_size; - /* now setup start, stride, count, and block arrays for + /* now setup start, stride, count, and block arrays for * the first call to H5Sselect_hyperslab(). */ for(i = 0; i < SS_DR_MAX_RANK; i++) { @@ -10877,10 +10885,10 @@ test_shape_same_dr__checkerboard(int test_num, start, stride, count, block); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* if small_rank == 1, or if edge_size == checker_size, we + /* if small_rank == 1, or if edge_size == checker_size, we * are done, as either there is no added dimension in which * to place offset selected "checkers". - * + * * Otherwise, set up start, stride, count and block, and * make the additional selection. */ @@ -10900,7 +10908,7 @@ test_shape_same_dr__checkerboard(int test_num, /* Wierdness alert: * - * Some how, it seems that selections can extend beyond the + * Some how, it seems that selections can extend beyond the * boundaries of the target data space -- hence the following * code to manually clip the selection back to the data space * proper. @@ -10923,8 +10931,8 @@ test_shape_same_dr__checkerboard(int test_num, /* Now select the checkerboard selection in the (possibly larger) n-cube. - * - * Since we have already calculated the base start, stride, count, + * + * Since we have already calculated the base start, stride, count, * and block, re-use the values in setting up start, stride, count, * and block. */ @@ -10968,10 +10976,10 @@ test_shape_same_dr__checkerboard(int test_num, start_ptr, stride_ptr, count_ptr, block_ptr); CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* As before, if the number of dimensions selected is less than or - * equal to 1, or if edge_size == checker_size, we are done, as - * either there is no added dimension in which to place offset selected - * "checkers", or the hyperslab is completely occupied by one + /* As before, if the number of dimensions selected is less than or + * equal to 1, or if edge_size == checker_size, we are done, as + * either there is no added dimension in which to place offset selected + * "checkers", or the hyperslab is completely occupied by one * "checker". * * Otherwise, set up start, stride, count and block, and @@ -11001,7 +11009,7 @@ test_shape_same_dr__checkerboard(int test_num, /* Wierdness alert: * - * Again, it seems that selections can extend beyond the + * Again, it seems that selections can extend beyond the * boundaries of the target data space -- hence the following * code to manually clip the selection back to the data space * proper. @@ -11018,7 +11026,7 @@ test_shape_same_dr__checkerboard(int test_num, CHECK(ret, FAIL, "H5Sselect_hyperslab"); /* setup is done -- run the test: */ - check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid); + check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "test_shape_same_dr__checkerboard"); @@ -11034,23 +11042,23 @@ test_shape_same_dr__checkerboard(int test_num, /**************************************************************** ** -** test_shape_same_dr__run_checkerboard_tests(): +** test_shape_same_dr__run_checkerboard_tests(): ** -** In this set of tests, we test H5S_select_shape_same() -** with a "checkerboard" selection of 1, 2, 3, and 4 cubes as -** one parameter, and 1, 2, 3, and 4 dimensional checkerboard -** slices through a n-cube of rank no more than 5 (and at -** least the rank of the slice). +** In this set of tests, we test H5S_select_shape_same() +** with a "checkerboard" selection of 1, 2, 3, and 4 cubes as +** one parameter, and 1, 2, 3, and 4 dimensional checkerboard +** slices through a n-cube of rank no more than 5 (and at +** least the rank of the slice). ** -** All the n-cubes will have lengths of the same size, so +** All the n-cubes will have lengths of the same size, so ** H5S_select_shape_same() should return true iff: ** -** 1) the rank of the n cube equals the number of dimensions -** selected in the checker board slice through the m-cube +** 1) the rank of the n cube equals the number of dimensions +** selected in the checker board slice through the m-cube ** (m >= n). ** -** 2) The dimensions selected in the checkerboard slice -** through the m-cube are the dimensions with the most +** 2) The dimensions selected in the checkerboard slice +** through the m-cube are the dimensions with the most ** quickly changing indices. ** ****************************************************************/ @@ -11101,7 +11109,7 @@ test_shape_same_dr__run_checkerboard_tests(void) dim_selected[4] = FALSE; else dim_selected[4] = TRUE; - + /* compute the expected result: */ i = 0; @@ -11305,17 +11313,17 @@ test_shape_same_dr__run_checkerboard_tests(void) /**************************************************************** ** -** test_shape_same_dr__irregular(): +** test_shape_same_dr__irregular(): ** -** Tests selection of an "irregular" subset of a full +** Tests selection of an "irregular" subset of a full ** n-cube data space vs an identical "irregular" subset ** of an n-dimensional slice of an m-cube (m > n). -** in a call to H5S_select_shape_same(). +** in a call to H5S_select_shape_same(). ** -** Note that this test does not require the n-cube and the +** Note that this test does not require the n-cube and the ** n-dimensional slice to have the same rank (although -** H5S_select_shape_same() should always return FALSE if -** they don't). +** H5S_select_shape_same() should always return FALSE if +** they don't). ** ****************************************************************/ static void @@ -11337,7 +11345,7 @@ test_shape_same_dr__irregular(int test_num, hid_t n_cube_0_sid; /* the hyper cube containing * an irregular selection */ - hid_t n_cube_1_sid; /* the hyper cube in which a + hid_t n_cube_1_sid; /* the hyper cube in which a * slice contains an irregular * selection. */ @@ -11373,7 +11381,7 @@ test_shape_same_dr__irregular(int test_num, hsize_t clip_block[SS_DR_MAX_RANK] = {10, 10, 10, 10, 10}; - hsize_t *(starts[SS_DR_MAX_RANK]) = + hsize_t *(starts[SS_DR_MAX_RANK]) = {start_0, start_1, start_2, start_3, start_4}; hsize_t *(strides[SS_DR_MAX_RANK]) = {stride_0, stride_1, stride_2, stride_3, stride_4}; @@ -11396,8 +11404,8 @@ test_shape_same_dr__irregular(int test_num, HDassert( 0 < small_rank ); HDassert( small_rank <= large_rank ); HDassert( large_rank <= SS_DR_MAX_RANK ); - HDassert( 9 <= edge_size ); - HDassert( edge_size <= 1000 ); + HDassert( 9 <= edge_size ); + HDassert( edge_size <= 1000 ); HDassert( 0 <= slice_offset ); HDassert( slice_offset < edge_size ); HDassert( -2 <= pattern_offset ); @@ -11410,16 +11418,16 @@ test_shape_same_dr__irregular(int test_num, HDassert( dims_selected >= 0 ); HDassert( dims_selected <= large_rank ); - sprintf(test_desc_0, - "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", + sprintf(test_desc_0, + "\tirregular sub set of n-cube slice through m-cube (n <= m) test %d.\n", test_num); MESSAGE(7, (test_desc_0)); /* This statement must be updated if SS_DR_MAX_RANK is changed */ - sprintf(test_desc_1, + sprintf(test_desc_1, "\tranks: %d/%d edge: %d s/p offset: %d/%d dim_selected: %d/%d/%d/%d/%d:%d.\n", small_rank, large_rank, - edge_size, + edge_size, slice_offset, pattern_offset, (int)dim_selected[0], (int)dim_selected[1], @@ -11438,11 +11446,11 @@ test_shape_same_dr__irregular(int test_num, CHECK(n_cube_0_sid, FAIL, "H5Screate_simple"); /* Select an "irregular" pattern in the small n-cube. This - * pattern can be though of a set of four 3 x 2 x 2 X 2 - * four dimensional prisims, each parallel to one of the - * axies and none of them intersecting with the other. + * pattern can be though of a set of four 3 x 2 x 2 X 2 + * four dimensional prisims, each parallel to one of the + * axies and none of them intersecting with the other. * - * In the lesser dimensional cases, this 4D pattern is + * In the lesser dimensional cases, this 4D pattern is * projected onto the lower dimensional space. * * In the 1-D case, the projection of the pattern looks @@ -11467,12 +11475,12 @@ test_shape_same_dr__irregular(int test_num, * 0 - - - - - - - - - - * 0 1 2 3 4 5 6 7 8 9 x * - * In both cases, asterisks indicate selected elements, + * In both cases, asterisks indicate selected elements, * and dashes indicate unselected elements. * * Note that is this case, since the edge size is fixed, - * the pattern does not change. However, we do use the - * displacement parameter to allow it to be moved around + * the pattern does not change. However, we do use the + * displacement parameter to allow it to be moved around * within the n-cube or hyper slab. */ @@ -11487,7 +11495,7 @@ test_shape_same_dr__irregular(int test_num, CHECK(ret, FAIL, "H5Sselect_hyperslab"); } /* end for */ - /* finally, clip the selection to ensure that it lies fully + /* finally, clip the selection to ensure that it lies fully * within the n-cube. */ ret = H5Sselect_hyperslab(n_cube_0_sid, H5S_SELECT_AND, @@ -11526,8 +11534,8 @@ test_shape_same_dr__irregular(int test_num, /* Now select the irregular selection in the (possibly larger) n-cube. - * - * Basic idea is to project the pattern used in the smaller n-cube + * + * Basic idea is to project the pattern used in the smaller n-cube * onto the dimensions selected in the larger n-cube, with the displacement * specified. */ @@ -11564,7 +11572,7 @@ test_shape_same_dr__irregular(int test_num, /* setup is done -- run the test: */ - check = H5S_select_shape_same_test(n_cube_0_sid, n_cube_1_sid); + check = H5S__select_shape_same_test(n_cube_0_sid, n_cube_1_sid); VERIFY(check, expected_result, "test_shape_same_dr__checkerboard"); @@ -11580,25 +11588,25 @@ test_shape_same_dr__irregular(int test_num, /**************************************************************** ** -** test_shape_same_dr__run_irregular_tests(): +** test_shape_same_dr__run_irregular_tests(): ** -** In this set of tests, we test H5S_select_shape_same() -** with an "irregular" subselection of 1, 2, 3, and 4 cubes as -** one parameter, and irregular subselections of 1, 2, 3, -** and 4 dimensional slices through a n-cube of rank no more -** than 5 (and at least the rank of the slice) as the other. -** Note that the "irregular" selection may be offset between +** In this set of tests, we test H5S_select_shape_same() +** with an "irregular" subselection of 1, 2, 3, and 4 cubes as +** one parameter, and irregular subselections of 1, 2, 3, +** and 4 dimensional slices through a n-cube of rank no more +** than 5 (and at least the rank of the slice) as the other. +** Note that the "irregular" selection may be offset between ** the n-cube and the slice. ** ** All the irregular selections will be identical (modulo rank) ** so H5S_select_shape_same() should return true iff: ** -** 1) the rank of the n cube equals the number of dimensions -** selected in the irregular slice through the m-cube +** 1) the rank of the n cube equals the number of dimensions +** selected in the irregular slice through the m-cube ** (m >= n). ** -** 2) The dimensions selected in the irregular slice -** through the m-cube are the dimensions with the most +** 2) The dimensions selected in the irregular slice +** through the m-cube are the dimensions with the most ** quickly changing indices. ** ****************************************************************/ @@ -11649,7 +11657,7 @@ test_shape_same_dr__run_irregular_tests(void) dim_selected[4] = FALSE; else dim_selected[4] = TRUE; - + /* compute the expected result: */ i = 0; @@ -11795,8 +11803,8 @@ test_shape_same_dr__run_irregular_tests(void) /**************************************************************** ** -** test_shape_same_dr(): Tests selections on dataspace with -** different ranks, to verify that "shape same" routine +** test_shape_same_dr(): Tests selections on dataspace with +** different ranks, to verify that "shape same" routine ** is now handling this case correctly. ** ****************************************************************/ @@ -11913,7 +11921,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_reg1); + rebuild_stat = H5S__get_rebuild_status_test(sid_reg1); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be TRUE. */ if(!rebuild_stat){ @@ -11922,7 +11930,7 @@ test_space_rebuild(void) } else { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S_select_shape_same_test(sid_reg1,sid_reg_ori1); + rebuild_check = H5S__select_shape_same_test(sid_reg1,sid_reg_ori1); CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); } @@ -11945,7 +11953,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_irreg1); + rebuild_stat = H5S__get_rebuild_status_test(sid_irreg1); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -11992,7 +12000,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_reg2); + rebuild_stat = H5S__get_rebuild_status_test(sid_reg2); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be TRUE. */ if(!rebuild_stat){ @@ -12001,7 +12009,7 @@ test_space_rebuild(void) } else { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S_select_shape_same_test(sid_reg2,sid_reg_ori2); + rebuild_check = H5S__select_shape_same_test(sid_reg2,sid_reg_ori2); CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); } @@ -12029,7 +12037,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_irreg2); + rebuild_stat = H5S__get_rebuild_status_test(sid_irreg2); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -12081,7 +12089,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_reg3); + rebuild_stat = H5S__get_rebuild_status_test(sid_reg3); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be TRUE. */ @@ -12091,7 +12099,7 @@ test_space_rebuild(void) } else { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S_select_shape_same_test(sid_reg3,sid_reg_ori3); + rebuild_check = H5S__select_shape_same_test(sid_reg3,sid_reg_ori3); CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); } @@ -12124,7 +12132,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_irreg3); + rebuild_stat = H5S__get_rebuild_status_test(sid_irreg3); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -12184,7 +12192,7 @@ test_space_rebuild(void) rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_reg4); + rebuild_stat = H5S__get_rebuild_status_test(sid_reg4); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be TRUE. */ if(!rebuild_stat){ @@ -12193,7 +12201,7 @@ test_space_rebuild(void) } else { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S_select_shape_same_test(sid_reg4,sid_reg_ori4); + rebuild_check = H5S__select_shape_same_test(sid_reg4,sid_reg_ori4); CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); } @@ -12237,7 +12245,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_irreg4); + rebuild_stat = H5S__get_rebuild_status_test(sid_irreg4); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -12301,7 +12309,7 @@ test_space_rebuild(void) rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_reg5); + rebuild_stat = H5S__get_rebuild_status_test(sid_reg5); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be TRUE. */ if(!rebuild_stat){ @@ -12310,7 +12318,7 @@ test_space_rebuild(void) } else { /* In this case, rebuild_check should be TRUE. */ - rebuild_check = H5S_select_shape_same_test(sid_reg5,sid_reg_ori5); + rebuild_check = H5S__select_shape_same_test(sid_reg5,sid_reg_ori5); CHECK(rebuild_check,FALSE,"H5S_hyper_rebuild"); } @@ -12359,7 +12367,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_irreg5); + rebuild_stat = H5S__get_rebuild_status_test(sid_irreg5); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -12400,7 +12408,7 @@ test_space_rebuild(void) ret = H5Sselect_hyperslab(sid_spec,H5S_SELECT_SET,start5,stride5,count5,block5); CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_spec); + rebuild_stat = H5S__get_rebuild_status_test(sid_spec); /* In this case, rebuild_stat should be TRUE. */ if(!rebuild_stat){ ret = FAIL; @@ -12422,7 +12430,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = TRUE; - rebuild_stat = H5S_get_rebuild_status_test(sid_spec); + rebuild_stat = H5S__get_rebuild_status_test(sid_spec); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(rebuild_stat){ @@ -12445,7 +12453,7 @@ test_space_rebuild(void) CHECK(ret, FAIL, "H5Sselect_hyperslab"); rebuild_stat = FALSE; - rebuild_stat = H5S_get_rebuild_status_test(sid_spec); + rebuild_stat = H5S__get_rebuild_status_test(sid_spec); assert(rebuild_stat!=FAIL); /* In this case, rebuild_stat should be FALSE. */ if(!rebuild_stat){ @@ -12861,9 +12869,9 @@ test_select_bounds(void) /* Get bounds for 'none' selection */ H5E_BEGIN_TRY { ret = H5Sget_select_bounds(sid, low_bounds, high_bounds); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Sget_select_bo unds"); - + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Sget_select_bo unds"); + /* Set point selection */ coord[0][0] = 3; coord[0][1] = 3; coord[1][0] = 3; coord[1][1] = 96; @@ -13040,14 +13048,14 @@ test_hyper_regular(void) /* Query if 'all' selection is regular hyperslab (should fail) */ H5E_BEGIN_TRY { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; - VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ H5E_BEGIN_TRY { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set 'none' selection */ ret = H5Sselect_none(sid); @@ -13056,14 +13064,14 @@ test_hyper_regular(void) /* Query if 'none' selection is regular hyperslab (should fail) */ H5E_BEGIN_TRY { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; - VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ H5E_BEGIN_TRY { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set point selection */ coord[0][0] = 3; coord[0][1] = 3; coord[0][2] = 3; @@ -13076,14 +13084,14 @@ test_hyper_regular(void) /* Query if 'point' selection is regular hyperslab (should fail) */ H5E_BEGIN_TRY { is_regular = H5Sis_regular_hyperslab(sid); - } H5E_END_TRY; - VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(is_regular, FAIL, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ H5E_BEGIN_TRY { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* Set "regular" hyperslab selection */ start[0] = 2; start[1] = 2; start[2] = 2; @@ -13095,7 +13103,7 @@ test_hyper_regular(void) /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */ is_regular = H5Sis_regular_hyperslab(sid); - VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab"); + VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab"); /* Retrieve the hyperslab parameters */ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); @@ -13121,13 +13129,13 @@ test_hyper_regular(void) /* Query if 'hyperslab' selection is regular hyperslab (should be FALSE) */ is_regular = H5Sis_regular_hyperslab(sid); - VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); + VERIFY(is_regular, FALSE, "H5Sis_regular_hyperslab"); /* Query regular hyperslab selection info (should fail) */ H5E_BEGIN_TRY { ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Sget_regular_hyperslab"); /* 'XOR' in the point again, to remove it, which should make it regular again */ t_start[0] = 0; t_start[1] = 0; t_start[2] = 0; @@ -13137,7 +13145,7 @@ test_hyper_regular(void) /* Query if 'hyperslab' selection is regular hyperslab (should be TRUE) */ is_regular = H5Sis_regular_hyperslab(sid); - VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab"); + VERIFY(is_regular, TRUE, "H5Sis_regular_hyperslab"); /* Retrieve the hyperslab parameters */ ret = H5Sget_regular_hyperslab(sid, q_start, q_stride, q_count, q_block); diff --git a/testpar/t_shapesame.c b/testpar/t_shapesame.c index eddbada..f5282bd 100644 --- a/testpar/t_shapesame.c +++ b/testpar/t_shapesame.c @@ -948,9 +948,9 @@ contig_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->small_ds_slice_sid, + check = H5S__select_shape_same_test(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* Read selection from disk */ @@ -1216,9 +1216,9 @@ contig_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->file_small_ds_sid_0, + check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* Read selection from disk */ @@ -1531,9 +1531,9 @@ contig_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * memory slice through the cube selection and the * on disk full square selections as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->file_small_ds_sid_0, + check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed."); + VRFY((check == TRUE), "H5S__select_shape_same_test passed."); /* write the slice from the in memory large data set to the @@ -1864,9 +1864,9 @@ contig_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * on disk slice through the large data set selection * as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->mem_small_ds_sid, + check = H5S__select_shape_same_test(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* write the small data set slice from memory to the @@ -3149,9 +3149,9 @@ ckrbrd_hs_dr_pio_test__d2m_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->small_ds_slice_sid, + check = H5S__select_shape_same_test(tv_ptr->small_ds_slice_sid, tv_ptr->file_large_ds_sid_0); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* Read selection from disk */ @@ -3415,9 +3415,9 @@ ckrbrd_hs_dr_pio_test__d2m_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->file_small_ds_sid_0, + check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_0, tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* Read selection from disk */ @@ -3800,9 +3800,9 @@ ckrbrd_hs_dr_pio_test__m2d_l2s(struct hs_dr_pio_test_vars_t * tv_ptr) * large dataset and the checkerboard selection of the process * slice of the small data set as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->file_small_ds_sid_1, + check = H5S__select_shape_same_test(tv_ptr->file_small_ds_sid_1, tv_ptr->mem_large_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed."); + VRFY((check == TRUE), "H5S__select_shape_same_test passed."); /* write the checker board selection of the slice from the in @@ -4155,9 +4155,9 @@ ckrbrd_hs_dr_pio_test__m2d_s2l(struct hs_dr_pio_test_vars_t * tv_ptr) * on disk slice through the large data set selection * as having the same shape. */ - check = H5S_select_shape_same_test(tv_ptr->mem_small_ds_sid, + check = H5S__select_shape_same_test(tv_ptr->mem_small_ds_sid, tv_ptr->file_large_ds_sid_1); - VRFY((check == TRUE), "H5S_select_shape_same_test passed"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed"); /* write the small data set slice from memory to the diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c index 02d2cca..cc79af2 100644 --- a/testpar/t_span_tree.c +++ b/testpar/t_span_tree.c @@ -2334,9 +2334,9 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(mem_large_ds_sid, + check = H5S__select_shape_same_test(mem_large_ds_sid, file_small_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed (1)"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed (1)"); ret = H5Dread(small_dataset, @@ -2455,9 +2455,9 @@ lower_dim_size_comp_test__run_test(const int chunk_edge_size, /* verify that H5S_select_shape_same() reports the two * selections as having the same shape. */ - check = H5S_select_shape_same_test(mem_small_ds_sid, + check = H5S__select_shape_same_test(mem_small_ds_sid, file_large_ds_sid); - VRFY((check == TRUE), "H5S_select_shape_same_test passed (2)"); + VRFY((check == TRUE), "H5S__select_shape_same_test passed (2)"); ret = H5Dread(large_dataset, @@ -2622,31 +2622,27 @@ void lower_dim_size_comp_test(void) { /* const char *fcnName = "lower_dim_size_comp_test()"; */ - int chunk_edge_size = 0; - int use_collective_io = 1; - hid_t dset_type = H5T_NATIVE_UINT; + int chunk_edge_size = 0; + int use_collective_io; + #if 0 HDsleep(60); #endif - HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned)); - for ( use_collective_io = (hbool_t)0; - (int)use_collective_io <= 1; - (hbool_t)(use_collective_io++) ) { + HDcompile_assert(sizeof(uint32_t) == sizeof(unsigned)); + for(use_collective_io = 0; use_collective_io <= 1; use_collective_io++) { chunk_edge_size = 0; lower_dim_size_comp_test__run_test(chunk_edge_size, (hbool_t)use_collective_io, - dset_type); - + H5T_NATIVE_UINT); chunk_edge_size = 5; lower_dim_size_comp_test__run_test(chunk_edge_size, (hbool_t)use_collective_io, - dset_type); - } + H5T_NATIVE_UINT); + } /* end for */ return; - } /* lower_dim_size_comp_test() */ -- cgit v0.12 From 3ed1ac0f1b760fe84ec009de19550d98f0b38071 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 13 Feb 2019 08:24:27 -0600 Subject: Add missing toolchain include for cross-compile --- config/cmake/scripts/HPC/sbatch-HDF5options.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake index dc97b3a..f70526e 100644 --- a/config/cmake/scripts/HPC/sbatch-HDF5options.cmake +++ b/config/cmake/scripts/HPC/sbatch-HDF5options.cmake @@ -34,6 +34,7 @@ if (DEFINED KNL) set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") set (LOCAL_BATCH_SCRIPT_NAME "knl_ctestS.sl") set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "knl_ctestP.sl") + set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_TOOLCHAIN_FILE:STRING=config/toolchain/crayle.cmake") else () set (LOCAL_BATCH_SCRIPT_NAME "ctestS.sl") set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.sl") -- cgit v0.12 From b95f05638ce40ccd944248f5865a248f39ef0d10 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 13 Feb 2019 15:53:25 -0600 Subject: TRILAB-111 fixes for parallel testing --- CTestConfig.cmake | 4 +- config/cmake/hdf5-config.cmake.in | 3 + config/cmake/scripts/CTestScript.cmake | 8 +- config/cmake/scripts/HPC/bsub-HDF5options.cmake | 13 +- config/cmake/scripts/HPC/raybsub-HDF5options.cmake | 13 +- config/toolchain/crayle.cmake | 10 - src/CMakeLists.txt | 2 +- test/CMakeTests.cmake | 97 +++--- test/CMakeVFDTests.cmake | 100 +++++- test/CMakeVOLTests.cmake | 106 ++++++- test/testframe.c | 338 +++++++++++---------- testpar/CMakeLists.txt | 2 +- testpar/CMakeTests.cmake | 68 ++++- testpar/CMakeVFDTests.cmake | 20 +- 14 files changed, 499 insertions(+), 285 deletions(-) diff --git a/CTestConfig.cmake b/CTestConfig.cmake index 5b35688..d80f48f 100644 --- a/CTestConfig.cmake +++ b/CTestConfig.cmake @@ -45,9 +45,9 @@ set (VALGRIND_COMMAND_OPTIONS "-v --tool=memcheck --leak-check=full --track-fds= set (CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") set (CTEST_MEMORYCHECK_COMMAND_OPTIONS "-v --tool=memcheck --leak-check=full --track-fds=yes --num-callers=50 --show-reachable=yes --track-origins=yes --malloc-fill=0xff --free-fill=0xfe") -set (CTEST_TEST_TIMEOUT 600 CACHE STRING +set (CTEST_TEST_TIMEOUT 1200 CACHE STRING "Maximum time allowed before CTest will kill the test.") -set (DART_TESTING_TIMEOUT 600 CACHE STRING +set (DART_TESTING_TIMEOUT 1200 CACHE STRING "Maximum time allowed before CTest will kill the test." FORCE) SET(CTEST_SUBMIT_RETRY_DELAY 20 CACHE STRING diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index e687a58..3bd9e1d 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -38,6 +38,7 @@ set (${HDF5_PACKAGE_NAME}_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) 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_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@) @@ -45,6 +46,8 @@ set (${HDF5_PACKAGE_NAME}_BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@) set (${HDF5_PACKAGE_NAME}_PACKAGE_EXTLIBS @HDF5_PACKAGE_EXTLIBS@) set (${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES @HDF5_LIBRARIES_TO_EXPORT@) set (${HDF5_PACKAGE_NAME}_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") +set (${HDF5_PACKAGE_NAME}_DEFAULT_API_VERSION "@DEFAULT_API_VERSION@") +set (${HDF5_PACKAGE_NAME}_PARALLEL_FILTERED_WRITES "@PARALLEL_FILTERED_WRITES@") #----------------------------------------------------------------------------- # Dependencies diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake index 0e2afc7..6958f31 100644 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -257,7 +257,7 @@ message (STATUS "Dashboard script configuration:\n${vars}\n") # On Cray XC40, configuring fails in the Fortran section when using the craype-mic-knl module. # When the configure phase is done with the craype-haswell module and the build phase is done # with the craype-mic-knl module, configure succeeds and tests pass on the knl compute nodes - # for Intel, Cray, GCC and Clang compilers. If the variables aren't set or if not + # for Intel, Cray, GCC and Clang compilers. If the variables aren't set or if not # cross compiling, the module switch will not occur. if (CMAKE_CROSSCOMPILING AND COMPILENODE_HWCOMPILE_MODULE AND COMPUTENODE_HWCOMPILE_MODULE) execute_process (COMMAND module switch ${COMPILENODE_HWCOMPILE_MODULE} ${COMPUTENODE_HWCOMPILE_MODULE}) @@ -277,11 +277,11 @@ message (STATUS "Dashboard script configuration:\n${vars}\n") ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) else () file(STRINGS ${CTEST_BINARY_DIRECTORY}/Testing/TAG TAG_CONTENTS REGEX "^2([0-9]+)[-]([0-9]+)$") - if ("${LOCAL_BATCH_SCRIPT_COMMAND}" STREQUAL "raybsub") + if (${LOCAL_BATCH_SCRIPT_COMMAND} STREQUAL "raybsub") execute_process (COMMAND ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_COMMAND} ${LOCAL_BATCH_SCRIPT_ARGS} ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_NAME}) else () execute_process (COMMAND ${LOCAL_BATCH_SCRIPT_COMMAND} ${LOCAL_BATCH_SCRIPT_ARGS} ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_NAME}) - endif () + endif () message(STATUS "Check for existence of ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml") execute_process(COMMAND ls ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml RESULT_VARIABLE result OUTPUT_QUIET ERROR_QUIET) while(result) @@ -296,7 +296,7 @@ message (STATUS "Dashboard script configuration:\n${vars}\n") file (RENAME ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/Test.xml ${CTEST_BINARY_DIRECTORY}/Testing/${TAG_CONTENTS}/SerialTest.xml) file (RENAME ${CTEST_BINARY_DIRECTORY}/Testing/Temporary/LastTest_${TAG_CONTENTS}.log ${CTEST_BINARY_DIRECTORY}/Testing/Temporary/LastTest_${TAG_CONTENTS}_Serial.log) unset(result CACHE) - if ("${LOCAL_BATCH_SCRIPT_COMMAND}" STREQUAL "raybsub") + if (${LOCAL_BATCH_SCRIPT_COMMAND} STREQUAL "raybsub") execute_process (COMMAND ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_COMMAND} ${LOCAL_BATCH_SCRIPT_ARGS} ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_PARALLEL_NAME}) else () execute_process (COMMAND ${LOCAL_BATCH_SCRIPT_COMMAND} ${LOCAL_BATCH_SCRIPT_ARGS} ${CTEST_BINARY_DIRECTORY}/${LOCAL_BATCH_SCRIPT_PARALLEL_NAME}) diff --git a/config/cmake/scripts/HPC/bsub-HDF5options.cmake b/config/cmake/scripts/HPC/bsub-HDF5options.cmake index a862a6b..83c17aa 100644 --- a/config/cmake/scripts/HPC/bsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/bsub-HDF5options.cmake @@ -33,17 +33,8 @@ set (LOCAL_BATCH_TEST "TRUE") set (LOCAL_BATCH_SCRIPT_NAME "ctestS.lsf") set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ctestP.lsf") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ctestS.lsf") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ctestP.lsf") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=${LOCAL_BATCH_SCRIPT_NAME}") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=${LOCAL_BATCH_SCRIPT_PARALLEL_NAME}") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=srun") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-n") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") - -############################################################################################# -### some additions and alternatives to cross compile on haswell for knl -#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") -#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") -#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") -############################################################################################# diff --git a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake index d3c8721..9775979 100644 --- a/config/cmake/scripts/HPC/raybsub-HDF5options.cmake +++ b/config/cmake/scripts/HPC/raybsub-HDF5options.cmake @@ -33,17 +33,8 @@ set (LOCAL_BATCH_TEST "TRUE") set (LOCAL_BATCH_SCRIPT_NAME "ray_ctestS.lsf") set (LOCAL_BATCH_SCRIPT_PARALLEL_NAME "ray_ctestP.lsf") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_TEST:BOOL=ON") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=ray_ctestS.lsf") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=ray_ctestP.lsf") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=${LOCAL_BATCH_SCRIPT_NAME}") +set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=${LOCAL_BATCH_SCRIPT_PARALLEL_NAME}") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_EXECUTABLE:STRING=mpirun") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_NUMPROC_FLAG:STRING=-np") set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DMPIEXEC_MAX_NUMPROCS:STRING=6") - -############################################################################################# -### some additions and alternatives to cross compile on haswell for knl -#set (COMPILENODE_HWCOMPILE_MODULE "craype-haswell") -#set (COMPUTENODE_HWCOMPILE_MODULE "craype-mic-knl") -#set (SITE_BUILDNAME_SUFFIX "knl-intel17-SHARED" -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_NAME:STRING=knl_ctestS.sl") -#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLOCAL_BATCH_SCRIPT_PARALLEL_NAME:STRING=knl_ctestP.sl") -############################################################################################# diff --git a/config/toolchain/crayle.cmake b/config/toolchain/crayle.cmake index 159f43a..bf7cf69 100644 --- a/config/toolchain/crayle.cmake +++ b/config/toolchain/crayle.cmake @@ -8,13 +8,3 @@ set(CMAKE_Fortran_COMPILER ftn) # the following is used if cross-compiling set(CMAKE_CROSSCOMPILING_EMULATOR "") - -# option to use pre-generated H5Tinit.c file -set(HDF5_USE_PREGEN OFF) -# directory where H5Tinit.c file will be found -#set(HDF5_USE_PREGEN_DIR "/lscratch1/lknox/HDF5_1_10_4/CMake-hdf5-1.10.4") - -# option to generate H5Tinit.c by running H5detect on knl compute node during build -#set(HDF5_BATCH_H5DETECT ON) -#set(HDF5_BATCH_CMD "sbatch") -#set(HDF5_BATCH_H5DETECT_SCRIPT "knl_H5detect.sl") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6b105a9..4d77a8b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -944,7 +944,7 @@ if (BUILD_SHARED_LIBS) endif () if (LOCAL_BATCH_TEST) - if ("${LOCAL_BATCH_SCRIPT_COMMAND}" STREQUAL "raybsub") + if (${LOCAL_BATCH_SCRIPT_COMMAND} STREQUAL "raybsub") configure_file ( ${HDF5_SOURCE_DIR}/bin/batch/${LOCAL_BATCH_SCRIPT_COMMAND} ${HDF5_BINARY_DIR}/${LOCAL_BATCH_SCRIPT_COMMAND} ESCAPE_QUOTES @ONLY diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index ba72e3a..b087172 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -231,47 +231,31 @@ add_test (NAME H5TEST-clear-testhdf5-objects ) set_tests_properties (H5TEST-clear-testhdf5-objects PROPERTIES FIXTURES_SETUP clear_testhdf5) -if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5TEST-testhdf5-base COMMAND $ -x heap -x file -x select) - set_tests_properties (H5TEST-testhdf5-base PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST - ) - add_test (NAME H5TEST-testhdf5-heap COMMAND $ -o heap) - set_tests_properties (H5TEST-testhdf5-heap PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST - ) - add_test (NAME H5TEST-testhdf5-file COMMAND $ -o file) - set_tests_properties (H5TEST-testhdf5-file PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST - ) - add_test (NAME H5TEST-testhdf5-select COMMAND $ -o select) - set_tests_properties (H5TEST-testhdf5-select PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST - ) -else () - add_test (NAME H5TEST-testhdf5 COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=testhdf5.txt" - #-D "TEST_REFERENCE=testhdf5.out" - -D "TEST_FOLDER=${HDF5_TEST_BINARY_DIR}/H5TEST" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5TEST-testhdf5 PROPERTIES - FIXTURES_REQUIRED clear_testhdf5 - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST - ) +add_test (NAME H5TEST-testhdf5-base COMMAND $ -x heap -x file -x select) +set_tests_properties (H5TEST-testhdf5-base PROPERTIES + FIXTURES_REQUIRED clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) +add_test (NAME H5TEST-testhdf5-heap COMMAND $ -o heap) +set_tests_properties (H5TEST-testhdf5-heap PROPERTIES + FIXTURES_REQUIRED clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) +add_test (NAME H5TEST-testhdf5-file COMMAND $ -o file) +set_tests_properties (H5TEST-testhdf5-file PROPERTIES + FIXTURES_REQUIRED clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) +add_test (NAME H5TEST-testhdf5-select COMMAND $ -o select) +set_tests_properties (H5TEST-testhdf5-select PROPERTIES + FIXTURES_REQUIRED clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) +if (NOT HDF5_ENABLE_USING_MEMCHECKER) if (BUILD_SHARED_LIBS) add_test (NAME H5TEST-shared-clear-testhdf5-objects COMMAND ${CMAKE_COMMAND} @@ -298,19 +282,28 @@ else () ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) set_tests_properties (H5TEST-shared-clear-testhdf5-objects PROPERTIES FIXTURES_SETUP shared_clear_testhdf5) - add_test (NAME H5TEST-shared-testhdf5 COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_EXPECT=0" - -D "TEST_SKIP_COMPARE=TRUE" - -D "TEST_OUTPUT=testhdf5.txt" - #-D "TEST_REFERENCE=testhdf5.out" - -D "TEST_FOLDER=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + add_test (NAME H5TEST-shared-testhdf5-base COMMAND $ -x heap -x file -x select) + set_tests_properties (H5TEST-shared-testhdf5-base PROPERTIES + FIXTURES_REQUIRED shared_clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) - set_tests_properties (H5TEST-shared-testhdf5 PROPERTIES + add_test (NAME H5TEST-shared-testhdf5-heap COMMAND $ -o heap) + set_tests_properties (H5TEST-shared-testhdf5-heap PROPERTIES FIXTURES_REQUIRED shared_clear_testhdf5 - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-testhdf5-file COMMAND $ -o file) + set_tests_properties (H5TEST-shared-testhdf5-file PROPERTIES + FIXTURES_REQUIRED shared_clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-testhdf5-select COMMAND $ -o select) + set_tests_properties (H5TEST-shared-testhdf5-select PROPERTIES + FIXTURES_REQUIRED shared_clear_testhdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) endif () diff --git a/test/CMakeVFDTests.cmake b/test/CMakeVFDTests.cmake index 9f03c40..0d51e25 100644 --- a/test/CMakeVFDTests.cmake +++ b/test/CMakeVFDTests.cmake @@ -111,32 +111,48 @@ endif () if ("${vfdtest}" STREQUAL "flush1" OR "${vfdtest}" STREQUAL "flush2") if ("${vfdname}" STREQUAL "multi" OR "${vfdname}" STREQUAL "split") if (NOT BUILD_SHARED_LIBS AND NOT ${HDF_CFG_NAME} MATCHES "Debug") + add_test ( + NAME VFD-${vfdname}-${vfdtest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}/${vfdname}-${vfdtest}.out + ${vfdname}/${vfdname}-${vfdtest}.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${vfdtest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out.err + ) add_test (NAME VFD-${vfdname}-${test}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared ) @@ -152,64 +168,96 @@ endif () endif () endif () else () + add_test ( + NAME VFD-${vfdname}-${vfdtest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}/${vfdname}-${vfdtest}.out + ${vfdname}/${vfdname}-${vfdtest}.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${vfdtest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out.err + ) add_test (NAME VFD-${vfdname}-${test}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared ) endif () endif () else () + add_test ( + NAME VFD-${vfdname}-${vfdtest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}/${vfdname}-${vfdtest}.out + ${vfdname}/${vfdname}-${vfdtest}.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS AND NOT "${vfdtest}" STREQUAL "cache") + add_test ( + NAME VFD-${vfdname}-${vfdtest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared ) @@ -218,32 +266,48 @@ endif () endmacro () macro (DO_VFD_TEST vfdtest vfdname resultcode) + add_test ( + NAME VFD-${vfdname}-${vfdtest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}/${vfdname}-${vfdtest}.out + ${vfdname}/${vfdname}-${vfdtest}.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${vfdtest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out + ${vfdname}-shared/${vfdname}-${vfdtest}-shared.out.err + ) add_test (NAME VFD-${vfdname}-${vfdtest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + DEPENDS VFD-${vfdname}-${vfdtest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared ) @@ -277,33 +341,49 @@ endif () endif () endif () if (HDF5_TEST_FHEAP_VFD) + add_test ( + NAME VFD-${vfdname}-fheap-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}/${vfdname}-fheap.out + ${vfdname}/${vfdname}-fheap.out.err + ) add_test (NAME VFD-${vfdname}-fheap COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-fheap" + -D "TEST_OUTPUT=${vfdname}-fheap.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-fheap PROPERTIES + DEPENDS VFD-${vfdname}-fheap-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-fheap-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-fheap-shared.out + ${vfdname}-shared/${vfdname}-fheap-shared.out.err + ) add_test (NAME VFD-${vfdname}-fheap-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-fheap-shared" + -D "TEST_OUTPUT=${vfdname}-fheap-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-fheap-shared PROPERTIES + DEPENDS VFD-${vfdname}-fheap-shared-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared diff --git a/test/CMakeVOLTests.cmake b/test/CMakeVOLTests.cmake index fdd7ba0..d7da159 100644 --- a/test/CMakeVOLTests.cmake +++ b/test/CMakeVOLTests.cmake @@ -108,32 +108,48 @@ endif () if ("${voltest}" STREQUAL "flush1" OR "${voltest}" STREQUAL "flush2") if ("${volname}" STREQUAL "multi" OR "${volname}" STREQUAL "split") if (NOT BUILD_SHARED_LIBS AND NOT ${HDF_CFG_NAME} MATCHES "Debug") + add_test ( + NAME VOL-${volname}-${voltest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}/${volname}-${voltest}.out + ${volname}/${volname}-${voltest}.out.err + ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_OUTPUT=${volname}-${voltest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) if (BUILD_SHARED_LIBS) - add_test (NAME VOL-${volname}-${test}-shared + add_test ( + NAME VOL-${volname}-${voltest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}-shared/${volname}-${voltest}-shared.out + ${volname}-shared/${volname}-${voltest}-shared.out.err + ) + add_test (NAME VOL-${volname}-${voltest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_OUTPUT=${volname}-${voltest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + DEPENDS VOL-${volname}-${voltest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared ) @@ -143,70 +159,102 @@ endif () COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}" ) if (BUILD_SHARED_LIBS) - add_test (NAME VOL-${volname}-${test}-shared + add_test (NAME VOL-${volname}-${voltest}-shared COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}-shared" ) endif () endif () else () + add_test ( + NAME VOL-${volname}-${voltest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}/${volname}-${voltest}.out + ${volname}/${volname}-${voltest}.out.err + ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_OUTPUT=${volname}-${voltest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) if (BUILD_SHARED_LIBS) - add_test (NAME VOL-${volname}-${test}-shared + add_test ( + NAME VOL-${volname}-${voltest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}-shared/${volname}-${voltest}-shared.out + ${volname}-shared/${volname}-${voltest}-shared.out.err + ) + add_test (NAME VOL-${volname}-${voltest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_OUTPUT=${volname}-${voltest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + DEPENDS VOL-${volname}-${voltest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared ) endif () endif () else () + add_test ( + NAME VOL-${volname}-${voltest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}/${volname}-${voltest}.out + ${volname}/${volname}-${voltest}.out.err + ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_OUTPUT=${volname}-${voltest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) if (BUILD_SHARED_LIBS AND NOT "${voltest}" STREQUAL "cache") + add_test ( + NAME VOL-${volname}-${voltest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}-shared/${volname}-${voltest}-shared.out + ${volname}-shared/${volname}-${voltest}-shared.out.err + ) add_test (NAME VOL-${volname}-${voltest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_OUTPUT=${volname}-${voltest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + DEPENDS VOL-${volname}-${voltest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared ) @@ -216,32 +264,48 @@ endif () macro (DO_VOL_TEST voltest volname volinfo resultcode) #message(STATUS "${voltest}-${volname} with ${volinfo}") + add_test ( + NAME VOL-${volname}-${voltest}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}/${volname}-${voltest}.out + ${volname}/${volname}-${voltest}.out.err + ) add_test (NAME VOL-${volname}-${voltest} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_OUTPUT=${volname}-${voltest}.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + DEPENDS VOL-${volname}-${voltest}-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VOL-${volname}-${voltest}-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}-shared/${volname}-${voltest}-shared.out + ${volname}-shared/${volname}-${voltest}-shared.out.err + ) add_test (NAME VOL-${volname}-${voltest}-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_OUTPUT=${volname}-${voltest}-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + DEPENDS VOL-${volname}-${voltest}-shared-clear-objects ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared ) @@ -276,33 +340,49 @@ endif () endif () endif () if (HDF5_TEST_FHEAP_VOL) + add_test ( + NAME VOL-${volname}-fheap-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}/${volname}-fheap.out + ${volname}/${volname}-fheap.out.err + ) add_test (NAME VOL-${volname}-fheap COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-fheap" + -D "TEST_OUTPUT=${volname}-fheap.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-fheap PROPERTIES + DEPENDS VOL-${volname}-fheap-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} ) if (BUILD_SHARED_LIBS) + add_test ( + NAME VOL-${volname}-fheap-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${volname}-shared/${volname}-fheap-shared.out + ${volname}-shared/${volname}-fheap-shared.out.err + ) add_test (NAME VOL-${volname}-fheap-shared COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VOL:STRING=${volinfo}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${volname}-fheap-shared" + -D "TEST_OUTPUT=${volname}-fheap-shared.out" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" -P "${HDF_RESOURCES_DIR}/volTest.cmake" ) set_tests_properties (VOL-${volname}-fheap-shared PROPERTIES + DEPENDS VOL-${volname}-fheap-shared-clear-objects TIMEOUT ${CTEST_VERY_LONG_TIMEOUT} ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared diff --git a/test/testframe.c b/test/testframe.c index 335118c..97b2d1f 100644 --- a/test/testframe.c +++ b/test/testframe.c @@ -15,7 +15,7 @@ * Programmer: Quincey Koziol * Tuesday, January 6, 2004 * - * Purpose: Provides support functions for the testing framework. + * Purpose: Provides support functions for the testing framework. * */ @@ -28,24 +28,25 @@ #define MAXTESTDESC 64 typedef struct TestStruct { - int NumErrors; - char Description[MAXTESTDESC]; - int SkipFlag; - char Name[MAXTESTNAME]; - void (*Call)(void); - void (*Cleanup)(void); - const void *Parameters; + int NumErrors; + char Description[MAXTESTDESC]; + int SkipFlag; + char Name[MAXTESTNAME]; + void (*Call)(void); + void (*Cleanup)(void); + const void *Parameters; } TestStruct; /* * Variables used by testing framework. */ +static int enable_error_stack = 0; /* enable error stack; disable=0 enable=1 */ static int num_errs = 0; /* Total number of errors during testing */ int TestVerbosity = VERBO_DEF; /* Default Verbosity is Low */ -static int Summary = 0; /* Show test summary. Default is no. */ -static int CleanUp = 1; /* Do cleanup or not. Default is yes. */ -static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */ +static int Summary = 0; /* Show test summary. Default is no. */ +static int CleanUp = 1; /* Do cleanup or not. Default is yes. */ +static int TestExpress = -1; /* Do TestExpress or not. -1 means not set yet. */ static TestStruct *Test = NULL; /* Array of tests */ static unsigned TestAlloc = 0; /* Size of the Test array */ static unsigned Index = 0; @@ -54,7 +55,7 @@ static const char *TestProgName = NULL; static void (*TestPrivateUsage)(void) = NULL; static int (*TestPrivateParser)(int ac, char *av[]) = NULL; - + /* * Setup a test function and add it to the list of tests. * It must have no parameters and returns void. @@ -74,12 +75,12 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con /* Sanity checking */ if (HDstrlen(TheDescr) >= MAXTESTDESC) { printf("Test description ('%s') too long, increase MAXTESTDESC(%d).\n", - TheDescr, MAXTESTDESC); + TheDescr, MAXTESTDESC); exit(EXIT_FAILURE); } /* end if */ if (HDstrlen(TheName) >= MAXTESTNAME) { printf("Test name too long, increase MAXTESTNAME(%d).\n", - MAXTESTNAME); + MAXTESTNAME); exit(EXIT_FAILURE); } /* end if */ @@ -102,12 +103,12 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con /* Set up test function */ HDstrcpy(Test[Index].Description, TheDescr); if(*TheName != '-') { - HDstrcpy(Test[Index].Name, TheName); - Test[Index].SkipFlag = 0; + HDstrcpy(Test[Index].Name, TheName); + Test[Index].SkipFlag = 0; } - else { /* skip test by default */ - HDstrcpy(Test[Index].Name, TheName+1); - Test[Index].SkipFlag = 1; + else { /* skip test by default */ + HDstrcpy(Test[Index].Name, TheName+1); + Test[Index].SkipFlag = 1; } Test[Index].Call = TheCall; Test[Index].Cleanup = Cleanup; @@ -118,7 +119,7 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con Index++; } - + /* * Initialize testing framework * @@ -130,8 +131,8 @@ AddTest(const char *TheName, void (*TheCall) (void), void (*Cleanup) (void), con * private options. Default to NULL which means none is provided. * * Modifications: - * Albert Cheng 2004/08/17 - * Added the ProgName, private_usage and private_parser arguments. + * Albert Cheng 2004/08/17 + * Added the ProgName, private_usage and private_parser arguments. */ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_parser)(int ac, char *av[])) { @@ -140,7 +141,8 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p * half the functions this test calls are private, so automatic error * reporting wouldn't do much good since it's triggered at the API layer. */ - H5Eset_auto2(H5E_DEFAULT, NULL, NULL); + if (enable_error_stack == 0) + H5Eset_auto2(H5E_DEFAULT, NULL, NULL); /* * Record the program name and private routines if provided. @@ -152,50 +154,50 @@ void TestInit(const char *ProgName, void (*private_usage)(void), int (*private_p TestPrivateParser = private_parser; } - + /* * Print test usage. - * First print the common test options, then the extra options if provided. + * First print the common test options, then the extra options if provided. * * Modification: - * 2004/08/18 Albert Cheng. Add TestPrivateUsage feature. + * 2004/08/18 Albert Cheng. Add TestPrivateUsage feature. */ void TestUsage(void) { - unsigned i; - - print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", - TestProgName, (TestPrivateUsage ? "" : "")); - print_func(" [-[e]x[clude] name]+ \n"); - print_func(" [-o[nly] name]+ \n"); - print_func(" [-b[egin] name] \n"); - print_func(" [-s[ummary]] \n"); - print_func(" [-c[leanoff]] \n"); - print_func(" [-h[elp]] \n"); - print_func("\n\n"); - print_func("verbose controls the amount of information displayed\n"); - print_func("exclude to exclude tests by name\n"); - print_func("only to name tests which should be run\n"); - print_func("begin start at the name of the test givin\n"); - print_func("summary prints a summary of test results at the end\n"); - print_func("cleanoff does not delete *.hdf files after execution of tests\n"); - print_func("help print out this information\n"); - if (TestPrivateUsage){ - print_func("\nExtra options\n"); - TestPrivateUsage(); - } - print_func("\n\n"); - print_func("This program currently tests the following: \n\n"); - print_func("%16s %s\n", "Name", "Description"); - print_func("%16s %s\n", "----", "-----------"); - - for (i = 0; i < Index; i++) - print_func("%16s %s\n", Test[i].Name, Test[i].Description); - - print_func("\n\n"); + unsigned i; + + print_func("Usage: %s [-v[erbose] (l[ow]|m[edium]|h[igh]|0-9)] %s\n", + TestProgName, (TestPrivateUsage ? "" : "")); + print_func(" [-[e]x[clude] name]+ \n"); + print_func(" [-o[nly] name]+ \n"); + print_func(" [-b[egin] name] \n"); + print_func(" [-s[ummary]] \n"); + print_func(" [-c[leanoff]] \n"); + print_func(" [-h[elp]] \n"); + print_func("\n\n"); + print_func("verbose controls the amount of information displayed\n"); + print_func("exclude to exclude tests by name\n"); + print_func("only to name tests which should be run\n"); + print_func("begin start at the name of the test givin\n"); + print_func("summary prints a summary of test results at the end\n"); + print_func("cleanoff does not delete *.hdf files after execution of tests\n"); + print_func("help print out this information\n"); + if (TestPrivateUsage){ + print_func("\nExtra options\n"); + TestPrivateUsage(); + } + print_func("\n\n"); + print_func("This program currently tests the following: \n\n"); + print_func("%16s %s\n", "Name", "Description"); + print_func("%16s %s\n", "----", "-----------"); + + for (i = 0; i < Index; i++) + print_func("%16s %s\n", Test[i].Name, Test[i].Description); + + print_func("\n\n"); } - + /* * Print test info. */ @@ -209,7 +211,7 @@ void TestInfo(const char *ProgName) print_func("Linked with hdf5 version %u.%u release %u\n", major, minor, release); } - + /* * Parse command line information. * argc, argv: the usual command line argument count and strings @@ -218,7 +220,7 @@ void TestInfo(const char *ProgName) * exit EXIT_FAILURE if error is encountered. * * Modification: - * 2004/08/18 Albert Cheng. Add extra_parse feature. + * 2004/08/18 Albert Cheng. Add extra_parse feature. */ void TestParseCmdLine(int argc, char *argv[]) { @@ -226,80 +228,82 @@ void TestParseCmdLine(int argc, char *argv[]) int ret_code; while (argv++, --argc > 0){ - if ((HDstrcmp(*argv, "-verbose") == 0) || - (HDstrcmp(*argv, "-v") == 0)) { - if (argc > 0){ - --argc; ++argv; - ParseTestVerbosity(*argv); - }else{ - TestUsage(); - exit(EXIT_FAILURE); - } - } - else if (((HDstrcmp(*argv, "-exclude") == 0) || - (HDstrcmp(*argv, "-x") == 0))) { - if (argc > 0){ - --argc; ++argv; - SetTest(*argv, SKIPTEST); - }else{ - TestUsage(); - exit(EXIT_FAILURE); - } - } - else if (((HDstrcmp(*argv, "-begin") == 0) || - (HDstrcmp(*argv, "-b") == 0))) { - if (argc > 0){ - --argc; ++argv; - SetTest(*argv, BEGINTEST); - }else{ - TestUsage(); - exit(EXIT_FAILURE); - } - } - else if (((HDstrcmp(*argv, "-only") == 0) || - (HDstrcmp(*argv, "-o") == 0))) { - if(argc > 0) { - unsigned Loop; - - --argc; ++argv; - - /* Skip all tests, then activate only one. */ + if ((HDstrcmp(*argv, "-verbose") == 0) || + (HDstrcmp(*argv, "-v") == 0)) { + if (argc > 0){ + --argc; ++argv; + ParseTestVerbosity(*argv); + }else{ + TestUsage(); + exit(EXIT_FAILURE); + } + } + else if (((HDstrcmp(*argv, "-exclude") == 0) || + (HDstrcmp(*argv, "-x") == 0))) { + if (argc > 0){ + --argc; ++argv; + SetTest(*argv, SKIPTEST); + }else{ + TestUsage(); + exit(EXIT_FAILURE); + } + } + else if (((HDstrcmp(*argv, "-begin") == 0) || + (HDstrcmp(*argv, "-b") == 0))) { + if (argc > 0){ + --argc; ++argv; + SetTest(*argv, BEGINTEST); + }else{ + TestUsage(); + exit(EXIT_FAILURE); + } + } + else if (((HDstrcmp(*argv, "-only") == 0) || + (HDstrcmp(*argv, "-o") == 0))) { + if(argc > 0) { + unsigned Loop; + + --argc; ++argv; + + /* Skip all tests, then activate only one. */ if(!skipped_all) { for(Loop = 0; Loop < Index; Loop++) Test[Loop].SkipFlag = 1; skipped_all = TRUE; } /* end if */ - SetTest(*argv, ONLYTEST); - } /* end if */ + SetTest(*argv, ONLYTEST); + } /* end if */ else { - TestUsage(); - exit(EXIT_FAILURE); - } - } - else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0)) - Summary = 1; - else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) { - TestUsage(); - exit(EXIT_SUCCESS); + TestUsage(); + exit(EXIT_FAILURE); } - else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0)) - SetTestNoCleanup(); - else { - /* non-standard option. Break out. */ - break; - } + } + else if ((HDstrcmp(*argv, "-summary") == 0) || (HDstrcmp(*argv, "-s") == 0)) + Summary = 1; + else if (HDstrcmp(*argv, "-enable-error-stack") == 0) + enable_error_stack = 1; + else if ((HDstrcmp(*argv, "-help") == 0) || (HDstrcmp(*argv, "-h") == 0)) { + TestUsage(); + exit(EXIT_SUCCESS); + } + else if ((HDstrcmp(*argv, "-cleanoff") == 0) || (HDstrcmp(*argv, "-c") == 0)) + SetTestNoCleanup(); + else { + /* non-standard option. Break out. */ + break; + } } /* Call extra parsing function if provided. */ if (NULL != TestPrivateParser){ - ret_code=TestPrivateParser(argc+1, argv-1); - if (ret_code != 0) - exit(EXIT_FAILURE); + ret_code=TestPrivateParser(argc+1, argv-1); + if (ret_code != 0) + exit(EXIT_FAILURE); } } - + /* * Perform Tests. */ @@ -314,10 +318,10 @@ void PerformTests(void) MESSAGE(2, ("Testing -- %s (%s) \n", Test[Loop].Description, Test[Loop].Name)); MESSAGE(5, ("===============================================\n")); Test[Loop].NumErrors = num_errs; - Test_parameters = Test[Loop].Parameters; - ALARM_ON; + Test_parameters = Test[Loop].Parameters; + ALARM_ON; Test[Loop].Call(); - ALARM_OFF; + ALARM_OFF; Test[Loop].NumErrors = num_errs - Test[Loop].NumErrors; MESSAGE(5, ("===============================================\n")); MESSAGE(5, ("There were %d errors detected.\n\n", (int)Test[Loop].NumErrors)); @@ -332,7 +336,7 @@ void PerformTests(void) print_func("All tests were successful. \n\n"); } - + /* * Display test summary. */ @@ -354,7 +358,7 @@ void TestSummary(void) print_func("\n\n"); } - + /* * Cleanup files from testing */ @@ -370,7 +374,7 @@ void TestCleanup(void) Test[Loop].Cleanup(); } - + /* * Shutdown the test infrastructure */ @@ -380,7 +384,7 @@ void TestShutdown(void) HDfree(Test); } - + /* * Retrieve the verbosity level for the testing framework */ @@ -504,16 +508,16 @@ int SetTestNoCleanup(void) void ParseTestVerbosity(char *argv) { if (*argv == 'l') - SetTestVerbosity(VERBO_LO); + SetTestVerbosity(VERBO_LO); else if (*argv == 'm') - SetTestVerbosity(VERBO_MED); + SetTestVerbosity(VERBO_MED); else if (*argv == 'h') - SetTestVerbosity(VERBO_HI); + SetTestVerbosity(VERBO_HI); else - SetTestVerbosity(atoi(argv)); + SetTestVerbosity(atoi(argv)); } - + /* * Retrieve the number of testing errors for the testing framework */ @@ -522,7 +526,7 @@ H5_ATTR_PURE int GetTestNumErrs(void) return(num_errs); } - + /* * Increment the number of testing errors */ @@ -531,7 +535,7 @@ void IncTestNumErrs(void) num_errs++; } - + /* * Retrieve the current Test Parameters pointer. */ @@ -540,7 +544,7 @@ H5_ATTR_PURE const void *GetTestParameters(void) return(Test_parameters); } - + /* * This routine is designed to provide equivalent functionality to 'printf' * and also increment the error count for the testing framework. @@ -563,7 +567,7 @@ TestErrPrintf(const char *format, ...) return ret_value; } - + /* * Set (control) which test will be tested. * SKIPTEST: skip this test @@ -576,41 +580,41 @@ void SetTest(const char *testname, int action) unsigned Loop; switch (action){ - case SKIPTEST: - for (Loop = 0; Loop < Index; Loop++) - if (HDstrcmp(testname, Test[Loop].Name) == 0){ - Test[Loop].SkipFlag = 1; - break; - } - break; - case BEGINTEST: - for (Loop = 0; Loop < Index; Loop++) { - if (HDstrcmp(testname, Test[Loop].Name) != 0) - Test[Loop].SkipFlag = 1; - else{ - /* Found it. Set it to run. Done. */ - Test[Loop].SkipFlag = 0; - break; - } - } - break; - case ONLYTEST: - for (Loop = 0; Loop < Index; Loop++) { - if (HDstrcmp(testname, Test[Loop].Name) == 0) { - /* Found it. Set it to run. Break to skip the rest. */ - Test[Loop].SkipFlag = 0; - break; - } - } - break; - default: - /* error */ - printf("*** ERROR: Unknown action (%d) for SetTest\n", action); - break; + case SKIPTEST: + for (Loop = 0; Loop < Index; Loop++) + if (HDstrcmp(testname, Test[Loop].Name) == 0){ + Test[Loop].SkipFlag = 1; + break; + } + break; + case BEGINTEST: + for (Loop = 0; Loop < Index; Loop++) { + if (HDstrcmp(testname, Test[Loop].Name) != 0) + Test[Loop].SkipFlag = 1; + else{ + /* Found it. Set it to run. Done. */ + Test[Loop].SkipFlag = 0; + break; + } + } + break; + case ONLYTEST: + for (Loop = 0; Loop < Index; Loop++) { + if (HDstrcmp(testname, Test[Loop].Name) == 0) { + /* Found it. Set it to run. Break to skip the rest. */ + Test[Loop].SkipFlag = 0; + break; + } + } + break; + default: + /* error */ + printf("*** ERROR: Unknown action (%d) for SetTest\n", action); + break; } } - + /* * Enable alarm on test execution, configurable by environment variable */ diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt index 0b3cbe3..71459c7 100644 --- a/testpar/CMakeLists.txt +++ b/testpar/CMakeLists.txt @@ -47,7 +47,7 @@ set (H5P_TESTS t_mpi t_bigio t_cache - t_cache_image + #t_cache_image t_pflush1 t_pflush2 t_pread diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index b71e7bc..12ccc58 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -15,17 +15,83 @@ ### T E S T I N G ### ############################################################################## ############################################################################## +# Remove any output file left over from previous test run +add_test (NAME MPI_TEST-clear-testphdf5-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ParaTest.h5 + WORKING_DIRECTORY + ${HDF5_TEST_PAR_BINARY_DIR} +) +set_tests_properties (MPI_TEST-clear-testphdf5-objects PROPERTIES FIXTURES_SETUP par_clear_testphdf5) -add_test (NAME MPI_TEST_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) +set (SKIP_testphdf5 "") +#if (${HDF5_OPENMPI_VERSION_SKIP}) +# set (SKIP_testphdf5 "${SKIP_testphdf5};-x;ecdsetw") +#endif () + +add_test (NAME MPI_TEST_testphdf5 COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS} ${SKIP_testphdf5}) +set_tests_properties (MPI_TEST_testphdf5 PROPERTIES + FIXTURES_REQUIRED par_clear_testphdf5 + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_PAR_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR} +) +if (NOT "${last_test}" STREQUAL "") + set_tests_properties (MPI_TEST_testphdf5 PROPERTIES DEPENDS ${last_test}) +endif () +set (last_test "MPI_TEST_testphdf5") + +#if (${HDF5_OPENMPI_VERSION_SKIP}) +# list (REMOVE_ITEM H5P_TESTS t_shapesame) +#endif () + +set (test_par_CLEANFILES + t_cache_image_00.h5 + t_cache_image_01.h5 + t_cache_image_02.h5 + flush.h5 + noflush.h5 + reloc_t_pread_data_file.h5 + reloc_t_pread_group_0_file.h5 + reloc_t_pread_group_1_file.h5 + shutdown.h5 + after_mpi_fin.h5 + #the following should have been removed by the programs + bigio_test.h5 + CacheTestDummy.h5 + t_filters_parallel.h5 + MPItest.h5 + ShapeSameTest.h5 +) + +# Remove any output file left over from previous test run +add_test (NAME MPI_TEST-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${test_par_CLEANFILES} + WORKING_DIRECTORY + ${HDF5_TEST_PAR_BINARY_DIR} +) +set_tests_properties (MPI_TEST-clear-objects PROPERTIES FIXTURES_SETUP par_clear_objects) foreach (testp ${H5P_TESTS}) add_test (NAME MPI_TEST_${testp} COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $ ${MPIEXEC_POSTFLAGS}) + set_tests_properties (MPI_TEST_${testp} PROPERTIES + FIXTURES_REQUIRED par_clear_objects + ENVIRONMENT "HDF5_ALARM_SECONDS=3600;srcdir=${HDF5_TEST_PAR_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR} + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (MPI_TEST_${testp} PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "MPI_TEST_${testp}") endforeach () # The t_pflush1 test is hard-coded to fail. set_tests_properties (MPI_TEST_t_pflush1 PROPERTIES WILL_FAIL "true") #set_property (TEST MPI_TEST_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") set_tests_properties (MPI_TEST_t_pflush2 PROPERTIES DEPENDS MPI_TEST_t_pflush1) +set_tests_properties (MPI_TEST_t_prestart PROPERTIES DEPENDS MPI_TEST_t_pshutdown) ############################################################################## ############################################################################## diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake index e2bf88a..de16a31 100644 --- a/testpar/CMakeVFDTests.cmake +++ b/testpar/CMakeVFDTests.cmake @@ -33,20 +33,36 @@ set (VFD_LIST ${VFD_LIST} direct) endif () +foreach (vfdtest ${VFD_LIST}) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") +endforeach () + macro (ADD_VFD_TEST vfdname resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) foreach (test ${H5P_VFD_TESTS}) add_test ( + NAME MPI_TEST_VFD-${vfdname}-${test}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${vfdname}-shared/${vfdname}-${test}.out + ${vfdname}-shared/${vfdname}-${test}.out.err + ) + add_test ( NAME MPI_TEST_VFD-${vfdname}-${test} COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${test}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${vfdname}-${test}.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) + set_tests_properties (MPI_TEST_VFD-${vfdname}-${test} PROPERTIES + DEPENDS MPI_TEST_VFD-${vfdname}-${test}-clear-objects + ENVIRONMENT "srcdir=${HDF5_TEST_PAR_BINARY_DIR}/${vfdname}" + WORKING_DIRECTORY ${HDF5_TEST_PAR_BINARY_DIR}/${vfdname} + ) endforeach () endif () endmacro () -- cgit v0.12