diff options
53 files changed, 1900 insertions, 1407 deletions
diff --git a/.gitattributes b/.gitattributes index de68733..1ca4739 100644 --- a/.gitattributes +++ b/.gitattributes @@ -192,12 +192,12 @@ java/examples/testfiles/examples.intro.H5_CreateGroup.txt -text java/examples/testfiles/examples.intro.H5_CreateGroupAbsoluteRelative.txt -text java/examples/testfiles/examples.intro.H5_CreateGroupDataset.txt -text java/examples/testfiles/examples.intro.H5_ReadWrite.txt -text -java/lib/ext/slf4j-nop-1.7.5.jar -text svneol=unset#application/zip -java/lib/ext/slf4j-simple-1.7.5.jar -text svneol=unset#application/zip +java/lib/ext/slf4j-nop-1.7.25.jar -text svneol=unset#application/zip +java/lib/ext/slf4j-simple-1.7.25.jar -text svneol=unset#application/zip java/lib/hamcrest-core.jar -text svneol=unset#application/java-archive java/lib/junit.jar -text svneol=unset#application/java-archive java/lib/simplelogger.properties -text -java/lib/slf4j-api-1.7.5.jar -text svneol=unset#application/zip +java/lib/slf4j-api-1.7.25.jar -text svneol=unset#application/zip java/src/CMakeLists.txt -text java/src/Makefile.am -text java/src/hdf/CMakeLists.txt -text diff --git a/CMakeLists.txt b/CMakeLists.txt index f24a957..b0640b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,9 +195,9 @@ set (HDF5_JAVA_JNI_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/jni) set (HDF5_JAVA_HDF5_SRC_DIR ${HDF5_SOURCE_DIR}/java/src/hdf) set (HDF5_JAVA_TEST_SRC_DIR ${HDF5_SOURCE_DIR}/java/test) set (HDF5_JAVA_LIB_DIR ${HDF5_SOURCE_DIR}/java/lib) -set (HDF5_JAVA_LOGGING_JAR ${HDF5_SOURCE_DIR}/java/lib/slf4j-api-1.7.5.jar) -set (HDF5_JAVA_LOGGING_NOP_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-nop-1.7.5.jar) -set (HDF5_JAVA_LOGGING_SIMPLE_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-simple-1.7.5.jar) +set (HDF5_JAVA_LOGGING_JAR ${HDF5_SOURCE_DIR}/java/lib/slf4j-api-1.7.25.jar) +set (HDF5_JAVA_LOGGING_NOP_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-nop-1.7.25.jar) +set (HDF5_JAVA_LOGGING_SIMPLE_JAR ${HDF5_SOURCE_DIR}/java/lib/ext/slf4j-simple-1.7.25.jar) #----------------------------------------------------------------------------- # parse the full version number from H5public.h and include in H5_VERS_INFO @@ -3136,9 +3136,9 @@ ./java/lib/hamcrest-core.jar ./java/lib/junit.jar ./java/lib/simplelogger.properties -./java/lib/slf4j-api-1.7.5.jar -./java/lib/ext/slf4j-nop-1.7.5.jar -./java/lib/ext/slf4j-simple-1.7.5.jar +./java/lib/slf4j-api-1.7.25.jar +./java/lib/ext/slf4j-nop-1.7.25.jar +./java/lib/ext/slf4j-simple-1.7.25.jar # CMake-specific Files ./config/cmake/cacheinit.cmake diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index 574f541..e687a58 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -61,8 +61,8 @@ endif () if (${HDF5_PACKAGE_NAME}_BUILD_JAVA) set (${HDF5_PACKAGE_NAME}_JAVA_INCLUDE_DIRS @PACKAGE_CURRENT_BUILD_DIR@/lib/jarhdf5-@HDF5_VERSION_STRING@.jar - @PACKAGE_CURRENT_BUILD_DIR@/lib/slf4j-api-1.7.5.jar - @PACKAGE_CURRENT_BUILD_DIR@/lib/slf4j-nop-1.7.5.jar + @PACKAGE_CURRENT_BUILD_DIR@/lib/slf4j-api-1.7.25.jar + @PACKAGE_CURRENT_BUILD_DIR@/lib/slf4j-nop-1.7.25.jar ) set (${HDF5_PACKAGE_NAME}_JAVA_LIBRARY "@PACKAGE_CURRENT_BUILD_DIR@/lib") set (${HDF5_PACKAGE_NAME}_JAVA_LIBRARIES "${${HDF5_PACKAGE_NAME}_JAVA_LIBRARY}") diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 68b817e..0c570c6 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -155,7 +155,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) target_include_directories (f90_ex_ph5example PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" ) target_compile_options(f90_ex_ph5example PRIVATE @@ -164,6 +164,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) # set_property(TARGET f90_ex_ph5example APPEND PROPERTY # LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> @@ -183,7 +184,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) target_include_directories (f90_ex_ph5example-shared PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" ) target_compile_options(f90_ex_ph5example-shared PRIVATE @@ -192,6 +193,7 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (f90_ex_ph5example-shared PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) # set_property(TARGET f90_ex_ph5example-shared APPEND PROPERTY # LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 5750d05..025fab5 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -81,7 +81,7 @@ add_executable (H5match_types ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h ${HDF5_F90_SRC_SOURCE_DIR}/H5match_types.c ) -target_include_directories(H5match_types PRIVATE "${HDF5_BINARY_DIR};${HDF5_SRC_DIR};${HDF5_F90_BINARY_DIR}") +target_include_directories(H5match_types PRIVATE "${HDF5_BINARY_DIR};${HDF5_SRC_DIR};${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/static/H5f90i_gen.h ${HDF5_F90_BINARY_DIR}/static/H5fortran_types.F90 @@ -137,7 +137,7 @@ set (f90CStub_C_SHHDRS add_library (${HDF5_F90_C_LIB_TARGET} STATIC ${f90CStub_C_SOURCES} ${f90CStub_C_HDRS}) target_include_directories(${HDF5_F90_C_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC) @@ -153,7 +153,7 @@ set (install_targets ${HDF5_F90_C_LIB_TARGET}) if (BUILD_SHARED_LIBS) add_library (${HDF5_F90_C_LIBSH_TARGET} SHARED ${f90CStub_C_SOURCES} ${f90CStub_C_SHHDRS}) target_include_directories(${HDF5_F90_C_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET} diff --git a/fortran/src/H5Fff.F90 b/fortran/src/H5Fff.F90 index a3bef37..358e421 100644 --- a/fortran/src/H5Fff.F90 +++ b/fortran/src/H5Fff.F90 @@ -42,6 +42,9 @@ MODULE H5F USE H5GLOBAL IMPLICIT NONE + ! Number of objects opened in H5open_f + INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ + CONTAINS !****s* H5F/h5fcreate_f ! @@ -616,9 +619,14 @@ CONTAINS INTEGER(SIZE_T), INTENT(OUT) :: obj_count END FUNCTION h5fget_obj_count_c END INTERFACE - + hdferr = h5fget_obj_count_c(file_id, obj_type, obj_count) + ! Don't include objects created by H5open in the H5F_OBJ_ALL_F count + IF(file_id.EQ.INT(H5F_OBJ_ALL_F,HID_T))THEN + obj_count = obj_count - H5OPEN_NUM_OBJ + ENDIF + END SUBROUTINE h5fget_obj_count_f !****s* H5F/h5fget_obj_ids_f diff --git a/fortran/src/H5_ff.F90 b/fortran/src/H5_ff.F90 index db57f03..f63e734 100644 --- a/fortran/src/H5_ff.F90 +++ b/fortran/src/H5_ff.F90 @@ -169,8 +169,10 @@ CONTAINS ! October 13, 2011 ! Fortran90 Interface: SUBROUTINE h5open_f(error) + USE H5F, ONLY : h5fget_obj_count_f, H5OPEN_NUM_OBJ IMPLICIT NONE INTEGER, INTENT(OUT) :: error + INTEGER(SIZE_T) :: H5OPEN_NUM_OBJ_LOC = 0 !***** INTERFACE @@ -612,6 +614,10 @@ CONTAINS H5_SZIP_EC_OM_F = H5LIB_flags(1) H5_SZIP_NN_OM_F = H5LIB_flags(2) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, H5OPEN_NUM_OBJ_LOC, error) + + H5OPEN_NUM_OBJ = H5OPEN_NUM_OBJ_LOC + END SUBROUTINE h5open_f !****s* H5LIB/h5close_f diff --git a/fortran/src/Makefile.am b/fortran/src/Makefile.am index a863a67..666f6cb 100644 --- a/fortran/src/Makefile.am +++ b/fortran/src/Makefile.am @@ -142,7 +142,7 @@ FORTRAN_API=yes # modules they depend upon are actually made. *sigh* H5f90global.lo: $(srcdir)/H5f90global.F90 H5fortran_types.lo H5_buildiface.lo: $(srcdir)/H5_buildiface.F90 -H5_ff.lo: $(srcdir)/H5_ff.F90 H5f90global.lo +H5_ff.lo: $(srcdir)/H5_ff.F90 H5Fff.lo H5f90global.lo H5Aff.lo: $(srcdir)/H5Aff.F90 H5f90global.lo H5Dff.lo: $(srcdir)/H5Dff.F90 H5f90global.lo H5Eff.lo: $(srcdir)/H5Eff.F90 H5f90global.lo diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index fc1add1..b862fcd 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -44,7 +44,7 @@ set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/${HDF_CFG_BUILD_TYPE add_library (${HDF5_F90_C_TEST_LIB_TARGET} STATIC t.c) set_source_files_properties (t.c PROPERTIES LANGUAGE C) target_include_directories(${HDF5_F90_C_TEST_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIB_TARGET} STATIC) @@ -60,7 +60,7 @@ set_target_properties (${HDF5_F90_C_TEST_LIB_TARGET} PROPERTIES if (BUILD_SHARED_LIBS) add_library (${HDF5_F90_C_TEST_LIBSH_TARGET} SHARED t.c) target_include_directories(${HDF5_F90_C_TEST_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_definitions(${HDF5_F90_C_TEST_LIBSH_TARGET} diff --git a/fortran/test/tH5F.F90 b/fortran/test/tH5F.F90 index d91ee9c..72920f2 100644 --- a/fortran/test/tH5F.F90 +++ b/fortran/test/tH5F.F90 @@ -103,6 +103,10 @@ CONTAINS ! INTEGER :: i, j + !number of objects + INTEGER(SIZE_T) :: obj_count + INTEGER(HID_T) :: t1, t2, t3, t4 + ! !data buffers ! @@ -133,11 +137,51 @@ CONTAINS CALL h5_fixname_f(filename2, fix_filename2, H5P_DEFAULT_F, error) if(error .ne. 0) stop + ! Test object counts + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t1, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t2, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t3, error) + CALL check(" h5tcopy_f",error,total_error) + CALL h5tcopy_f(H5T_NATIVE_CHARACTER, t4, error) + CALL check(" h5tcopy_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.4)THEN + total_error = total_error + 1 + ENDIF + ! !Create first file "mount1.h5" using default properties. ! CALL h5fcreate_f(fix_filename1, H5F_ACC_TRUNC_F, file1_id, error) - CALL check("h5fcreate_f",error,total_error) + CALL check("h5fcreate_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.5)THEN + total_error = total_error + 1 + ENDIF + + CALL h5tclose_f(t1, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t2, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t3, error) + CALL check("h5tclose_f",error,total_error) + CALL h5tclose_f(t4, error) + CALL check("h5tclose_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.1)THEN + total_error = total_error + 1 + ENDIF ! !Create group "/G" inside file "mount1.h5". @@ -211,9 +255,23 @@ CONTAINS ! CALL h5fopen_f (fix_filename1, H5F_ACC_RDWR_F, file1_id, error) CALL check("hfopen_f",error,total_error) + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.1)THEN + total_error = total_error + 1 + ENDIF + CALL h5fopen_f (fix_filename2, H5F_ACC_RDWR_F, file2_id, error) CALL check("h5fopen_f",error,total_error) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.2)THEN + total_error = total_error + 1 + ENDIF ! !mount the second file under the first file's "/G" group. ! @@ -245,6 +303,7 @@ CONTAINS do i = 1, NX do j = 1, NY IF (data_out(i,j) .NE. data_in(i, j)) THEN + total_error = total_error + 1 END IF end do end do @@ -267,11 +326,26 @@ CONTAINS ! !Close both files. ! + + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.2)THEN + total_error = total_error + 1 + ENDIF + CALL h5fclose_f(file1_id, error) CALL check("h5fclose_f",error,total_error) CALL h5fclose_f(file2_id, error) CALL check("h5fclose_f",error,total_error) + CALL h5fget_obj_count_f(INT(H5F_OBJ_ALL_F,HID_T), H5F_OBJ_ALL_F, obj_count, error) + CALL check(" h5fget_obj_count_f",error,total_error) + + IF(obj_count.NE.0)THEN + total_error = total_error + 1 + ENDIF + if(cleanup) CALL h5_cleanup_f(filename1, H5P_DEFAULT_F, error) CALL check("h5_cleanup_f", error, total_error) if(cleanup) CALL h5_cleanup_f(filename2, H5P_DEFAULT_F, error) diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index fddfcf8..7ec3b63 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -56,7 +56,7 @@ set (HDF5_HL_F90_HEADERS ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTf90proto.h) add_library (${HDF5_HL_F90_C_LIB_TARGET} STATIC ${HDF5_HL_F90_C_SOURCES} ${HDF5_HL_F90_HEADERS}) target_include_directories(${HDF5_HL_F90_C_LIB_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} STATIC) @@ -72,7 +72,7 @@ set (install_targets ${HDF5_HL_F90_C_LIB_TARGET}) if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_F90_C_LIBSH_TARGET} SHARED ${HDF5_HL_F90_C_SOURCES} ${HDF5_HL_F90_HEADERS}) target_include_directories(${HDF5_HL_F90_C_LIBSH_TARGET} - PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) target_compile_definitions(${HDF5_LIBSH_TARGET} diff --git a/java/examples/datasets/JavaDatasetExample.sh.in b/java/examples/datasets/JavaDatasetExample.sh.in index 740b07d..cb16d45 100644 --- a/java/examples/datasets/JavaDatasetExample.sh.in +++ b/java/examples/datasets/JavaDatasetExample.sh.in @@ -52,8 +52,8 @@ test -d $BLDLIBDIR || mkdir -p $BLDLIBDIR # Comment '#' without space can be used. # -------------------------------------------------------------------- LIST_LIBRARY_FILES=" -$HDFLIB_HOME/slf4j-api-1.7.5.jar -$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar +$HDFLIB_HOME/slf4j-api-1.7.25.jar +$HDFLIB_HOME/ext/slf4j-simple-1.7.25.jar $top_builddir/src/.libs/libhdf5.* $top_builddir/java/src/jni/.libs/libhdf5_java.* $top_builddir/java/src/$JARFILE @@ -117,7 +117,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR() # skip rm if srcdir is same as destdir # this occurs when build/test performed in source dir and # make cp fail - SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.5.jar` + SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.25.jar` INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then @@ -183,7 +183,7 @@ JAVAEXEFLAGS=@H5_JAVAFLAGS@ COPY_LIBFILES_TO_BLDLIBDIR COPY_DATAFILES_TO_BLDDIR -CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE"" +CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.25.jar:"$BLDLIBDIR"/slf4j-simple-1.7.25.jar:"$TESTJARFILE"" TEST=/usr/bin/test if [ ! -x /usr/bin/test ] diff --git a/java/examples/datasets/Makefile.am b/java/examples/datasets/Makefile.am index ddd6d39..b442603 100644 --- a/java/examples/datasets/Makefile.am +++ b/java/examples/datasets/Makefile.am @@ -28,7 +28,7 @@ classes: pkgpath = examples/datasets hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar -CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.25.jar:$$CLASSPATH jarfile = jar$(PACKAGE_TARNAME)datasets.jar diff --git a/java/examples/datatypes/JavaDatatypeExample.sh.in b/java/examples/datatypes/JavaDatatypeExample.sh.in index 590a547..033442a 100644 --- a/java/examples/datatypes/JavaDatatypeExample.sh.in +++ b/java/examples/datatypes/JavaDatatypeExample.sh.in @@ -49,8 +49,8 @@ test -d $BLDLIBDIR || mkdir -p $BLDLIBDIR # Comment '#' without space can be used. # -------------------------------------------------------------------- LIST_LIBRARY_FILES=" -$HDFLIB_HOME/slf4j-api-1.7.5.jar -$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar +$HDFLIB_HOME/slf4j-api-1.7.25.jar +$HDFLIB_HOME/ext/slf4j-simple-1.7.25.jar $top_builddir/src/.libs/libhdf5.* $top_builddir/java/src/jni/.libs/libhdf5_java.* $top_builddir/java/src/$JARFILE @@ -114,7 +114,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR() # skip rm if srcdir is same as destdir # this occurs when build/test performed in source dir and # make cp fail - SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.5.jar` + SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.25.jar` INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then @@ -179,7 +179,7 @@ JAVAEXEFLAGS=@H5_JAVAFLAGS@ COPY_LIBFILES_TO_BLDLIBDIR COPY_DATAFILES_TO_BLDDIR -CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE"" +CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.25.jar:"$BLDLIBDIR"/slf4j-simple-1.7.25.jar:"$TESTJARFILE"" TEST=/usr/bin/test if [ ! -x /usr/bin/test ] diff --git a/java/examples/datatypes/Makefile.am b/java/examples/datatypes/Makefile.am index f6e58f1..5e0e971 100644 --- a/java/examples/datatypes/Makefile.am +++ b/java/examples/datatypes/Makefile.am @@ -28,7 +28,7 @@ classes: pkgpath = examples/datatypes hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar -CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.25.jar:$$CLASSPATH jarfile = jar$(PACKAGE_TARNAME)datatypes.jar diff --git a/java/examples/groups/JavaGroupExample.sh.in b/java/examples/groups/JavaGroupExample.sh.in index 53c0045..36df02e 100644 --- a/java/examples/groups/JavaGroupExample.sh.in +++ b/java/examples/groups/JavaGroupExample.sh.in @@ -51,8 +51,8 @@ test -d $BLDREFDIR || mkdir -p $BLDREFDIR # Comment '#' without space can be used. # -------------------------------------------------------------------- LIST_LIBRARY_FILES=" -$HDFLIB_HOME/slf4j-api-1.7.5.jar -$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar +$HDFLIB_HOME/slf4j-api-1.7.25.jar +$HDFLIB_HOME/ext/slf4j-simple-1.7.25.jar $top_builddir/src/.libs/libhdf5.* $top_builddir/java/src/jni/.libs/libhdf5_java.* $top_builddir/java/src/$JARFILE @@ -109,7 +109,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR() # skip rm if srcdir is same as destdir # this occurs when build/test performed in source dir and # make cp fail - SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.5.jar` + SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.25.jar` INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then @@ -225,7 +225,7 @@ COPY_LIBFILES_TO_BLDLIBDIR COPY_DATAFILES_TO_BLDDIR COPY_REFFILES_TO_BLDREFDIR -CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE"" +CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.25.jar:"$BLDLIBDIR"/slf4j-simple-1.7.25.jar:"$TESTJARFILE"" TEST=/usr/bin/test if [ ! -x /usr/bin/test ] diff --git a/java/examples/groups/Makefile.am b/java/examples/groups/Makefile.am index 4da17f9..09df743 100644 --- a/java/examples/groups/Makefile.am +++ b/java/examples/groups/Makefile.am @@ -28,7 +28,7 @@ classes: pkgpath = examples/groups hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar -CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.25.jar:$$CLASSPATH jarfile = jar$(PACKAGE_TARNAME)groups.jar diff --git a/java/examples/intro/JavaIntroExample.sh.in b/java/examples/intro/JavaIntroExample.sh.in index 3c3036a..077146d 100644 --- a/java/examples/intro/JavaIntroExample.sh.in +++ b/java/examples/intro/JavaIntroExample.sh.in @@ -49,8 +49,8 @@ test -d $BLDLIBDIR || mkdir -p $BLDLIBDIR # Comment '#' without space can be used. # -------------------------------------------------------------------- LIST_LIBRARY_FILES=" -$HDFLIB_HOME/slf4j-api-1.7.5.jar -$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar +$HDFLIB_HOME/slf4j-api-1.7.25.jar +$HDFLIB_HOME/ext/slf4j-simple-1.7.25.jar $top_builddir/src/.libs/libhdf5.* $top_builddir/java/src/jni/.libs/libhdf5_java.* $top_builddir/java/src/$JARFILE @@ -103,7 +103,7 @@ CLEAN_LIBFILES_AND_BLDLIBDIR() # skip rm if srcdir is same as destdir # this occurs when build/test performed in source dir and # make cp fail - SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.5.jar` + SDIR=`$DIRNAME $HDFLIB_HOME/slf4j-api-1.7.25.jar` INODE_SDIR=`$LS -i -d $SDIR | $AWK -F' ' '{print $1}'` INODE_DDIR=`$LS -i -d $BLDLIBDIR | $AWK -F' ' '{print $1}'` if [ "$INODE_SDIR" != "$INODE_DDIR" ]; then @@ -168,7 +168,7 @@ JAVAEXEFLAGS=@H5_JAVAFLAGS@ COPY_LIBFILES_TO_BLDLIBDIR COPY_DATAFILES_TO_BLDDIR -CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE"" +CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/slf4j-api-1.7.25.jar:"$BLDLIBDIR"/slf4j-simple-1.7.25.jar:"$TESTJARFILE"" TEST=/usr/bin/test if [ ! -x /usr/bin/test ] diff --git a/java/examples/intro/Makefile.am b/java/examples/intro/Makefile.am index 0df08cb..33f44c2 100644 --- a/java/examples/intro/Makefile.am +++ b/java/examples/intro/Makefile.am @@ -28,7 +28,7 @@ classes: pkgpath = examples/intro hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar -CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.25.jar:$$CLASSPATH jarfile = jar$(PACKAGE_TARNAME)intro.jar diff --git a/java/lib/ext/slf4j-nop-1.7.25.jar b/java/lib/ext/slf4j-nop-1.7.25.jar Binary files differnew file mode 100644 index 0000000..78c7295 --- /dev/null +++ b/java/lib/ext/slf4j-nop-1.7.25.jar diff --git a/java/lib/ext/slf4j-nop-1.7.5.jar b/java/lib/ext/slf4j-nop-1.7.5.jar Binary files differdeleted file mode 100644 index e55bdd8..0000000 --- a/java/lib/ext/slf4j-nop-1.7.5.jar +++ /dev/null diff --git a/java/lib/ext/slf4j-simple-1.7.25.jar b/java/lib/ext/slf4j-simple-1.7.25.jar Binary files differnew file mode 100644 index 0000000..b29ca12 --- /dev/null +++ b/java/lib/ext/slf4j-simple-1.7.25.jar diff --git a/java/lib/ext/slf4j-simple-1.7.5.jar b/java/lib/ext/slf4j-simple-1.7.5.jar Binary files differdeleted file mode 100644 index 9dece31..0000000 --- a/java/lib/ext/slf4j-simple-1.7.5.jar +++ /dev/null diff --git a/java/lib/slf4j-api-1.7.25.jar b/java/lib/slf4j-api-1.7.25.jar Binary files differnew file mode 100644 index 0000000..7e62f13 --- /dev/null +++ b/java/lib/slf4j-api-1.7.25.jar diff --git a/java/lib/slf4j-api-1.7.5.jar b/java/lib/slf4j-api-1.7.5.jar Binary files differdeleted file mode 100644 index 8766455..0000000 --- a/java/lib/slf4j-api-1.7.5.jar +++ /dev/null diff --git a/java/src/Makefile.am b/java/src/Makefile.am index 64eef0c..bd55c39 100644 --- a/java/src/Makefile.am +++ b/java/src/Makefile.am @@ -37,7 +37,7 @@ jarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar hdf5_javadir = $(libdir) pkgpath = hdf/hdf5lib -CLASSPATH_ENV=CLASSPATH=.:$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$$CLASSPATH AM_JAVACFLAGS = $(H5_JAVACFLAGS) -deprecation diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index f826fbc..f58623e 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -1746,20 +1746,15 @@ public class H5 implements java.io.Serializable { status = H5Dread_double(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (double[]) obj, isCriticalPinning); } - else if (H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { + else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { log.trace("H5Dread_reg_ref"); status = H5Dread_reg_ref(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (String[]) obj); } else if (is1D && (dataClass.getComponentType() == String.class)) { log.trace("H5Dread_string type"); - if (H5.H5Tis_variable_str(mem_type_id)) { - status = H5Dread_VLStrings(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj); - } - else { - status = H5Dread_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, + status = H5Dread_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (String[]) obj); - } } else { // Create a data buffer to hold the data into a Java Array @@ -1979,7 +1974,7 @@ public class H5 implements java.io.Serializable { Class dataClass = obj.getClass(); if (!dataClass.isArray()) { - throw (new HDF5JavaException("H5Dread: data is not an array")); + throw (new HDF5JavaException("H5Dwrite: data is not an array")); } String cname = dataClass.getName(); @@ -2012,13 +2007,8 @@ public class H5 implements java.io.Serializable { } else if (is1D && (dataClass.getComponentType() == String.class)) { log.trace("H5Dwrite_string type"); - if (H5.H5Tis_variable_str(mem_type_id)) { - status = H5Dwrite_VLStrings(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (Object[]) obj); - } - else { - status = H5Dwrite_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, + status = H5Dwrite_string(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (String[]) obj); - } } else { HDFArray theArray = new HDFArray(obj); @@ -2084,6 +2074,9 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Dwrite_string(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, long xfer_plist_id, String[] buf) throws HDF5LibraryException, NullPointerException; + public synchronized static native int H5DwriteVL(long dataset_id, long mem_type_id, long mem_space_id, + long file_space_id, long xfer_plist_id, Object[] buf) throws HDF5LibraryException, NullPointerException; + /** * H5Dwrite_VLStrings writes a (partial) variable length String dataset, specified by its identifier dataset_id, from * the application memory buffer buf into the file. diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 43109f2..7eddac0 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -623,6 +623,7 @@ public class HDF5Constants { public static final long H5T_UNIX_D64LE = H5T_UNIX_D64LE(); public static final long H5T_VARIABLE = H5T_VARIABLE(); public static final int H5T_VLEN = H5T_VLEN(); + public static final int H5T_VL_T = H5T_VL_T(); public static final int H5Z_CB_CONT = H5Z_CB_CONT(); public static final int H5Z_CB_ERROR = H5Z_CB_ERROR(); public static final int H5Z_CB_FAIL = H5Z_CB_FAIL(); @@ -1825,6 +1826,8 @@ public class HDF5Constants { private static native final int H5T_VLEN(); + private static native final int H5T_VL_T(); + private static native final int H5Z_CB_CONT(); private static native final int H5Z_CB_ERROR(); diff --git a/java/src/hdf/hdf5lib/HDFArray.java b/java/src/hdf/hdf5lib/HDFArray.java index 529aecb..30f0fc8 100644 --- a/java/src/hdf/hdf5lib/HDFArray.java +++ b/java/src/hdf/hdf5lib/HDFArray.java @@ -1025,8 +1025,11 @@ class ArrayDescriptor { NTsize = 8; } else if (css.startsWith("Ljava.lang.String")) { + NT = 'L'; + className = "java.lang.String"; + NTsize = 1; throw new HDF5JavaException(new String( - "ArrayDesciptor: Error: String array not supported yet")); + "ArrayDesciptor: Warning: String array not fully supported yet")); } else { /* diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index 0f4361f..c99745d 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -1231,6 +1231,8 @@ JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VARIABLE(JNIEnv *env, jclass cls) { return (int)H5T_VARIABLE; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VLEN(JNIEnv *env, jclass cls) { return H5T_VLEN; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index 26ec4fc..13f5207 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -49,6 +49,10 @@ extern jobject visit_callback; /* 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 H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *op_data); @@ -178,7 +182,6 @@ Java_hdf_hdf5lib_H5_H5Aread } /* end if */ else { status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, byteP); - if (status < 0) { ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); h5libraryError(env); @@ -194,6 +197,323 @@ Java_hdf_hdf5lib_H5_H5Aread /* * Class: hdf_hdf5lib_H5 + * Method: H5AwriteVL + * Signature: (JJ[Ljava/lang/String;)I + */ +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 <nm; i++) { + hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); + isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || + H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); + H5Tclose(nested_tid); + } + } + else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { + isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ + } + if (isStr == 0 || isComplex>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); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */ + +herr_t +H5AwriteVL_str + (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +{ + herr_t status = -1; + char **wdata; + jsize size; + jint i; + + size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + + 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++) { + if(wdata[i]) { + HDfree(wdata[i]); + } /* end if */ + } /* end for */ + HDfree(wdata); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} + +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 */ + + /* + 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); + */ + + HDfree(strs); + } /* end else */ + } /* end else */ + + return status; +} /* end H5AwriteVL_str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadVL + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +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 <nm; i++) { + hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); + isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || + H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); + H5Tclose(nested_tid); + } + } + else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { + isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ + } + if (isStr == 0 || isComplex>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); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread_1VL */ + +herr_t +H5AreadVL_asstr + (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; + + /* 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 */ + + return status; +} + +herr_t +H5AreadVL_str + (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 */ + + /* + 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); + */ + + HDfree(strs); + } /* end else */ + } /* end else */ + + return status; +} /* end H5AreadVL_str */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Aget_space * Signature: (J)J */ diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h index 62769fd..f3758eb 100644 --- a/java/src/jni/h5aImp.h +++ b/java/src/jni/h5aImp.h @@ -69,6 +69,24 @@ Java_hdf_hdf5lib_H5_H5Aread /* * Class: hdf_hdf5lib_H5 + * Method: H5AwriteVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AwriteVL + (JNIEnv *, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AreadVL + (JNIEnv *, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Aget_space * Signature: (J)J */ diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 9784055..cea6bb4 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -56,6 +56,7 @@ extern jobject visit_callback; 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); @@ -993,96 +994,6 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1double /* * Class: hdf_hdf5lib_H5 - * Method: H5DreadVL - * Signature: (JJJJJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -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 isVlenStr=0; - - if (buf == NULL) { - h5nullArgument(env, "H5DreadVL: buf is NULL"); - } /* end if */ - else { - isVlenStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - - if (isVlenStr) - h5badArgument(env, "H5DreadVL: type is not variable length non-string"); - else - 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); - } /* end else */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */ - -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; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - rdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); - if (rdata == NULL) { - h5JNIFatalError(env, "H5DreadVL_notstr: failed to allocate buff for read"); - } /* end if */ - else { - status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, rdata); - - if (status < 0) { - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, rdata); - HDfree(rdata); - h5JNIFatalError(env, "H5DreadVL_notstr: failed to read data"); - } /* end if */ - else { - max_len = 1; - for (i=0; i < n; i++) { - if ((rdata + i)->len > max_len) - max_len = (rdata + i)->len; - } - - 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_notstr: failed to allocate buf"); - } /* end if */ - else { - for (i=0; i < n; i++) { - h5str.s[0] = '\0'; - h5str_sprintf(&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 */ - - return status; -} - -/* - * Class: hdf_hdf5lib_H5 * Method: H5Dread_string * Signature: (JJJJJ[Ljava/lang/String;)I */ @@ -1218,6 +1129,120 @@ Java_hdf_hdf5lib_H5_H5Dwrite_1string return (jint)status; } /* end Java_hdf_hdf5lib_H5_H5Dwrite_1string */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5DreadVL + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +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; + + 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 <nm; i++) { + hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); + isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || + H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); + H5Tclose(nested_tid); + } + } + else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { + isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ + } + if (isStr == 0 || isComplex>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); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dread_1VL */ + +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; + + /* 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 (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 */ + + return status; +} + /** * Read VLEN data into array of arrays. * Object[] buf contains VL arrays of data points @@ -1305,6 +1330,104 @@ H5DreadVL_str /* * 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) +{ + herr_t status = -1; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 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 <nm; i++) { + hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); + isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || + H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); + H5Tclose(nested_tid); + } + } + else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { + isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ + } + if (isStr == 0 || isComplex>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); + } + 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); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Dwrite_1VL */ + +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; + + /* Get size of string array */ + n = ENVPTR->GetArrayLength(ENVPAR buf); + wdata = (hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); + + 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 (utf8) { + h5str_vlconvert(utf8, did, tid, wdata+i, 0); + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for (i = 0; i < size; ++i) */ + + status = H5Dwrite(did, tid, mem_sid, file_sid, xfer_plist_id, wdata); + + /* now free memory*/ + for (i = 0; i < n; i++) { + if(wdata+i) { + HDfree(wdata+i); + } /* end if */ + } /* end for */ + HDfree(wdata); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return status; +} /* end H5DwriteVL_asstr */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_VLStrings * Signature: (JJJJJ[Ljava/lang/String;)I */ @@ -1347,7 +1470,7 @@ H5DwriteVL_str wdata = (char**)HDmalloc((size_t)size * sizeof (char*)); if (!wdata) { - h5JNIFatalError(env, "H5DwriteVL_string: cannot allocate buffer"); + h5JNIFatalError(env, "H5DwriteVL_str: cannot allocate buffer"); } /* end if */ else { HDmemset(wdata, 0, (size_t)size * sizeof(char*)); @@ -1433,7 +1556,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref h5str_new(&h5str, 1024); for (i=0; i<n; i++) { h5str.s[0] = '\0'; - h5str_sprintf(&h5str, did, tid, ref_data[i], 0); + h5str_sprintf(&h5str, did, tid, ref_data[i], 0, 0); jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h index 3cf24fe..1fe71a8 100644 --- a/java/src/jni/h5dImp.h +++ b/java/src/jni/h5dImp.h @@ -213,6 +213,15 @@ Java_hdf_hdf5lib_H5_H5DreadVL /* * Class: hdf_hdf5lib_H5 + * Method: H5DwriteVL + * Signature: (JJJJJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5DwriteVL +(JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Dread_string * Signature: (JJJJJ[Ljava/lang/String;)I */ diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index 9a98202..33dca7f 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -21,6 +21,7 @@ extern "C" { #endif /* __cplusplus */ +#include <jni.h> #include <stdio.h> #include <string.h> #include <stdlib.h> @@ -152,6 +153,513 @@ 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. + */ +size_t +h5str_vlconvert + (char *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; + + this_str = NULL; + this_strlen = 0; + + switch (tclass) { + case H5T_COMPOUND: + { + unsigned i; + n = H5Tget_nmembers(tid); + + /* remove compound indicators */ + if (str[0] == ' ') + str++; + if (str[0] == '{') + str++; + + 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); + } + /* remove compound indicators */ + if (str[0] == '}') + str++; + if (str[0] == ' ') + str++; + } + 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); + size = 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]; + + 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 */ + + return this_strlen; +} /* end h5str_vlconvert */ + +/** 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; + + /* 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 */ + + this_strlen = HDstrlen(this_str); + + 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)); + } +#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)); + } + } + 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)); + } + } + 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: + { + 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] == '}') + break; + } + H5Tclose(mtid); + /* remove vlen indicators */ + if ((*str)[0] == '}') + (*str)++; + } + break; + + default: + { + /* All other types get copied raw */ + HDmemcpy(ucptr, this_str, size); + } + break; + } /* end switch */ + + return this_strlen; +} /* end h5str_convert */ + +/** 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; + + /* 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 */ + + this_str = NULL; + this_strlen = 0; + + switch (tclass) { + 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, ((char *) (ptr->p)) + offset, ptr->len, expand_data); + if ((i + 1) < n) + h5str_append(str, ", "); + H5Tclose(mtid); + } + h5str_append(str, "} "); + } + 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); + + H5Tget_array_dims2(tid, dims); + + total_elmts = 1; + for (i = 0; i < rank; i++) + total_elmts *= dims[i]; + + h5str_sprintf(str, container, mtid, ((char *) (ptr->p)), ptr->len, expand_data); + H5Tclose(mtid); + h5str_append(str, " ] "); + } + 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 */ + /** print value of a data point into string. Return Value: On success, the total number of characters printed is returned. @@ -159,7 +667,7 @@ h5str_append */ size_t h5str_sprintf - (h5str_t *str, hid_t container, hid_t tid, void *ptr, int expand_data) + (h5str_t *str, hid_t container, hid_t tid, void *ptr, int ptr_len, int expand_data) { unsigned char tmp_uchar = 0; char tmp_char = 0; @@ -182,9 +690,8 @@ h5str_sprintf char *this_str; size_t this_strlen; int n; - hvl_t *vlptr; - char *cptr = (char*) ptr; - unsigned char *ucptr = (unsigned char*) ptr; + 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); @@ -206,20 +713,20 @@ h5str_sprintf case H5T_FLOAT: if (sizeof(float) == size) { /* if (H5Tequal(tid, H5T_NATIVE_FLOAT)) */ - HDmemcpy(&tmp_float, ptr, sizeof(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, ptr, sizeof(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, ptr, sizeof(long double)); + HDmemcpy(&tmp_ldouble, cptr, sizeof(long double)); this_str = (char*)HDmalloc(27); sprintf(this_str, "%Lf", tmp_ldouble); } @@ -256,13 +763,13 @@ h5str_sprintf if (sizeof(char) == size) { if(H5T_SGN_NONE == nsign) { /* if (H5Tequal(tid, H5T_NATIVE_UCHAR)) */ - HDmemcpy(&tmp_uchar, ptr, sizeof(unsigned char)); + 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, ptr, sizeof(char)); + HDmemcpy(&tmp_char, cptr, sizeof(char)); this_str = (char*)HDmalloc(7); sprintf(this_str, "%hhd", tmp_char); } @@ -270,13 +777,13 @@ h5str_sprintf else if (sizeof(int) == size) { if(H5T_SGN_NONE == nsign) { /* if (H5Tequal(tid, H5T_NATIVE_UINT)) */ - HDmemcpy(&tmp_uint, ptr, sizeof(unsigned int)); + 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, ptr, sizeof(int)); + HDmemcpy(&tmp_int, cptr, sizeof(int)); this_str = (char*)HDmalloc(14); sprintf(this_str, "%d", tmp_int); } @@ -284,13 +791,13 @@ h5str_sprintf else if (sizeof(short) == size) { if(H5T_SGN_NONE == nsign) { /* if (H5Tequal(tid, H5T_NATIVE_USHORT)) */ - HDmemcpy(&tmp_ushort, ptr, sizeof(unsigned short)); + HDmemcpy(&tmp_ushort, cptr, sizeof(unsigned short)); this_str = (char*)HDmalloc(9); sprintf(this_str, "%u", tmp_ushort); } else { /* if (H5Tequal(tid, H5T_NATIVE_SHORT)) */ - HDmemcpy(&tmp_short, ptr, sizeof(short)); + HDmemcpy(&tmp_short, cptr, sizeof(short)); this_str = (char*)HDmalloc(9); sprintf(this_str, "%d", tmp_short); } @@ -298,13 +805,13 @@ h5str_sprintf else if (sizeof(long) == size) { if(H5T_SGN_NONE == nsign) { /* if (H5Tequal(tid, H5T_NATIVE_ULONG)) */ - HDmemcpy(&tmp_ulong, ptr, sizeof(unsigned long)); + HDmemcpy(&tmp_ulong, cptr, sizeof(unsigned long)); this_str = (char*)HDmalloc(23); sprintf(this_str, "%lu", tmp_ulong); } else { /* if (H5Tequal(tid, H5T_NATIVE_LONG)) */ - HDmemcpy(&tmp_long, ptr, sizeof(long)); + HDmemcpy(&tmp_long, cptr, sizeof(long)); this_str = (char*)HDmalloc(23); sprintf(this_str, "%ld", tmp_long); } @@ -312,13 +819,13 @@ h5str_sprintf else if (sizeof(long long) == size) { if(H5T_SGN_NONE == nsign) { /* if (H5Tequal(tid, H5T_NATIVE_ULLONG)) */ - HDmemcpy(&tmp_ullong, ptr, sizeof(unsigned long long)); + 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, ptr, sizeof(long long)); + HDmemcpy(&tmp_llong, cptr, sizeof(long long)); this_str = (char*)HDmalloc(25); sprintf(this_str, fmt_llong, tmp_llong); } @@ -333,8 +840,8 @@ h5str_sprintf 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, expand_data); - if (i < n - 1) + h5str_sprintf(str, container, mtid, cptr + offset, ptr_len, expand_data); + if ((i + 1) < n) h5str_append(str, ", "); H5Tclose(mtid); } @@ -344,7 +851,7 @@ h5str_sprintf case H5T_ENUM: { char enum_name[1024]; - if (H5Tenum_nameof(tid, ptr, enum_name, sizeof enum_name) >= 0) { + if (H5Tenum_nameof(tid, cptr, enum_name, sizeof enum_name) >= 0) { h5str_append(str, enum_name); } else { @@ -363,7 +870,7 @@ h5str_sprintf } break; case H5T_REFERENCE: - if (h5str_is_zero(ptr, size)) { + if (h5str_is_zero(cptr, size)) { h5str_append(str, "NULL"); } else { @@ -379,9 +886,9 @@ h5str_sprintf 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, ptr); + region_obj = H5Rdereference2(container, H5P_DEFAULT, H5R_DATASET_REGION, cptr); if (region_obj >= 0) { - region = H5Rget_region(container, H5R_DATASET_REGION, ptr); + region = H5Rget_region(container, H5R_DATASET_REGION, cptr); if (region >= 0) { if(expand_data) { region_type = H5Sget_select_type(region); @@ -393,7 +900,7 @@ h5str_sprintf } } else { - if(H5Rget_name(region_obj, H5R_DATASET_REGION, ptr, (char*)ref_name, 1024) >= 0) { + if(H5Rget_name(region_obj, H5R_DATASET_REGION, cptr, (char*)ref_name, 1024) >= 0) { h5str_append(str, ref_name); } @@ -424,7 +931,7 @@ h5str_sprintf hid_t obj; this_str = (char*)HDmalloc(64); - obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, ptr); + obj = H5Rdereference2(container, H5P_DEFAULT, H5R_OBJECT, cptr); H5Oget_info2(obj, &oi, H5O_INFO_ALL); /* Print object data and close object */ @@ -450,31 +957,30 @@ h5str_sprintf total_elmts *= dims[i]; for (i = 0; i < total_elmts; i++) { - h5str_sprintf(str, container, mtid, cptr + i * size, expand_data); - if (i < total_elmts - 1) + h5str_sprintf(str, container, mtid, cptr + i * size, ptr_len, expand_data); + if ((i + 1) < total_elmts) h5str_append(str, ", "); } H5Tclose(mtid); - h5str_append(str, "] "); + h5str_append(str, " ] "); } break; case H5T_VLEN: - { - unsigned int i; - mtid = H5Tget_super(tid); - size = H5Tget_size(mtid); - - vlptr = (hvl_t *) cptr; - - nll = vlptr->len; - for (i = 0; i < (int)nll; i++) { - h5str_sprintf(str, container, mtid, ((char *) (vlptr->p)) + i * size, expand_data); - if (i < (int)nll - 1) - h5str_append(str, ", "); + { + 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, ", "); + } + H5Tclose(mtid); + h5str_append(str, "}"); } - H5Tclose(mtid); - } - break; + break; default: { @@ -563,7 +1069,7 @@ h5str_print_region_data_blocks 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), 1); + h5str_sprintf(str, region_id, type_id, ((char*)region_buf + numindex * type_size), 0, 1); if (numindex + 1 < numelem) h5str_append(str, ", "); @@ -763,7 +1269,7 @@ h5str_print_region_data_points for (jndx = 0; jndx < npoints; jndx++) { if(H5Sget_simple_extent_dims(mem_space, total_size, NULL) >= 0) { - h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 1); + h5str_sprintf(str, region_id, type_id, ((char*)region_buf + jndx * type_size), 0, 1); if (jndx + 1 < npoints) h5str_append(str, ", "); @@ -1883,7 +2389,7 @@ h5tools_dump_simple_data /* Render the data element*/ h5str_new(&buffer, 32 * size); - bytes_in = h5str_sprintf(&buffer, container, type, memref, 1); + bytes_in = h5str_sprintf(&buffer, container, type, memref, 0, 1); if(i > 0) { HDfprintf(stream, ", "); if (line_count >= H5TOOLS_TEXT_BLOCK) { @@ -1909,116 +2415,6 @@ h5tools_dump_simple_data /* * Class: hdf_hdf5lib_H5 - * Method: H5AwriteVL - * Signature: (JJ[Ljava/lang/String;)I - */ -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; - char **wdata; - jsize size; - jint i; - - size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); - - wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); - if (!wdata) { - h5JNIFatalError(env, "H5AwriteVL: 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)attr_id, (hid_t)mem_type_id, wdata); - - 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 */ - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5AwriteVL */ - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5AreadVL - * Signature: (JJ[Ljava/lang/String;)I - */ -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; - jstring jstr; - char **strs; - int i, n; - hid_t sid; - hsize_t dims[H5S_MAX_RANK]; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - - strs =(char **)HDmalloc((size_t)n * sizeof(char *)); - if (strs == NULL) { - h5JNIFatalError( env, "H5AreadVL: failed to allocate buff for read variable length strings"); - } /* end if */ - else { - status = H5Aread(attr_id, mem_type_id, strs); - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(mem_type_id, sid, H5P_DEFAULT, strs); - H5Sclose(sid); - HDfree(strs); - h5JNIFatalError(env, "H5AreadVL: 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); - HDfree (strs[i]); - } /* end for */ - - /* - for repeatedly reading an attribute 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 "free(strs[i])" to free individual strings - after it is done. - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); - */ - - HDfree(strs); - } /* end else */ - } /* end else */ - return status; -} /* end Java_hdf_hdf5lib_H5_H5AreadVL */ - -/* - * Class: hdf_hdf5lib_H5 * Method: H5AreadComplex * Signature: (JJ[Ljava/lang/String;)I */ @@ -2059,7 +2455,7 @@ Java_hdf_hdf5lib_H5_H5AreadComplex 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); + 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 */ diff --git a/java/src/jni/h5util.h b/java/src/jni/h5util.h index 434a107..23bc424 100644 --- a/java/src/jni/h5util.h +++ b/java/src/jni/h5util.h @@ -39,7 +39,10 @@ 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_sprintf(h5str_t *str, hid_t container, hid_t tid, void *buf, int expand_data); +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_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); @@ -47,24 +50,6 @@ extern int h5str_dump_region_points_data(h5str_t *str, hid_t region, hid_t r /* * Class: hdf_hdf5lib_H5 - * Method: H5AwriteVL - * Signature: (JJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AwriteVL - (JNIEnv *, jclass, jlong, jlong, jobjectArray); - -/* - * Class: hdf_hdf5lib_H5 - * Method: H5AreadVL - * Signature: (JJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadVL - (JNIEnv *, jclass, jlong, jlong, jobjectArray); - -/* - * Class: hdf_hdf5lib_H5 * Method: H5AreadComplex * Signature: (JJ[Ljava/lang/String;)I */ diff --git a/java/test/Makefile.am b/java/test/Makefile.am index 65ff43f..6635ef7 100644 --- a/java/test/Makefile.am +++ b/java/test/Makefile.am @@ -28,7 +28,7 @@ classes: pkgpath = test hdfjarfile = jar$(PACKAGE_TARNAME)-$(PACKAGE_VERSION).jar -CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/junit.jar:$(top_srcdir)/java/lib/hamcrest-core.jar:$(top_srcdir)/java/lib/slf4j-api-1.7.5.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.5.jar:$$CLASSPATH +CLASSPATH_ENV=CLASSPATH=.:$(JAVAROOT):$(top_builddir)/java/src/$(hdfjarfile):$(top_srcdir)/java/lib/junit.jar:$(top_srcdir)/java/lib/hamcrest-core.jar:$(top_srcdir)/java/lib/slf4j-api-1.7.25.jar:$(top_srcdir)/java/lib/ext/slf4j-simple-1.7.25.jar:$$CLASSPATH jarfile = jar$(PACKAGE_TARNAME)test.jar diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 07c3242..5d69bee 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -62,8 +62,8 @@ $top_builddir/java/src/jni/.libs/libhdf5_java.* LIST_JAR_FILES=" $HDFLIB_HOME/hamcrest-core.jar $HDFLIB_HOME/junit.jar -$HDFLIB_HOME/slf4j-api-1.7.5.jar -$HDFLIB_HOME/ext/slf4j-simple-1.7.5.jar +$HDFLIB_HOME/slf4j-api-1.7.25.jar +$HDFLIB_HOME/ext/slf4j-simple-1.7.25.jar $top_builddir/java/src/$JARFILE " LIST_DATA_FILES=" @@ -249,7 +249,7 @@ JAVAEXEFLAGS=@H5_JAVAFLAGS@ COPY_LIBFILES_TO_BLDLIBDIR COPY_DATAFILES_TO_BLDDIR -CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/junit.jar:"$BLDLIBDIR"/hamcrest-core.jar:"$BLDLIBDIR"/slf4j-api-1.7.5.jar:"$BLDLIBDIR"/slf4j-simple-1.7.5.jar:"$TESTJARFILE"" +CPATH=".:"$BLDLIBDIR"/"$JARFILE":"$BLDLIBDIR"/junit.jar:"$BLDLIBDIR"/hamcrest-core.jar:"$BLDLIBDIR"/slf4j-api-1.7.25.jar:"$BLDLIBDIR"/slf4j-simple-1.7.25.jar:"$TESTJARFILE"" TEST=/usr/bin/test if [ ! -x /usr/bin/test ] @@ -309,7 +309,9 @@ if diff JUnit-TestH5.out JUnit-TestH5.txt > /dev/null; then echo " PASSED JUnit-TestH5" else echo "**FAILED** JUnit-TestH5" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5.txt JUnit-TestH5.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Eparams" @@ -328,7 +330,9 @@ if diff JUnit-TestH5Eparams.out JUnit-TestH5Eparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Eparams" else echo "**FAILED** JUnit-TestH5Eparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Eparams.txt JUnit-TestH5Eparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Eregister" @@ -347,7 +351,9 @@ if diff JUnit-TestH5Eregister.out JUnit-TestH5Eregister.txt > /dev/null; then echo " PASSED JUnit-TestH5Eregister" else echo "**FAILED** JUnit-TestH5Eregister" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Eregister.txt JUnit-TestH5Eregister.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Fparams" @@ -366,7 +372,9 @@ if diff JUnit-TestH5Fparams.out JUnit-TestH5Fparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Fparams" else echo "**FAILED** JUnit-TestH5Fparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Fparams.txt JUnit-TestH5Fparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Fbasic" @@ -385,7 +393,9 @@ if diff JUnit-TestH5Fbasic.out JUnit-TestH5Fbasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Fbasic" else echo "**FAILED** JUnit-TestH5Fbasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Fbasic.txt JUnit-TestH5Fbasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5F" @@ -404,7 +414,9 @@ if diff JUnit-TestH5F.out JUnit-TestH5F.txt > /dev/null; then echo " PASSED JUnit-TestH5F" else echo "**FAILED** JUnit-TestH5F" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5F.txt JUnit-TestH5F.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Fswmr" @@ -423,7 +435,9 @@ if diff JUnit-TestH5Fswmr.out JUnit-TestH5Fswmr.txt > /dev/null; then echo " PASSED JUnit-TestH5Fswmr" else echo "**FAILED** JUnit-TestH5Fswmr" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Fswmr.txt JUnit-TestH5Fswmr.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Gbasic" @@ -442,7 +456,9 @@ if diff JUnit-TestH5Gbasic.out JUnit-TestH5Gbasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Gbasic" else echo "**FAILED** JUnit-TestH5Gbasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Gbasic.txt JUnit-TestH5Gbasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5G" @@ -461,7 +477,9 @@ if diff JUnit-TestH5G.out JUnit-TestH5G.txt > /dev/null; then echo " PASSED JUnit-TestH5G" else echo "**FAILED** JUnit-TestH5G" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5G.txt JUnit-TestH5G.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Sbasic" @@ -480,7 +498,9 @@ if diff JUnit-TestH5Sbasic.out JUnit-TestH5Sbasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Sbasic" else echo "**FAILED** JUnit-TestH5Sbasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Sbasic.txt JUnit-TestH5Sbasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5S" @@ -499,7 +519,9 @@ if diff JUnit-TestH5S.out JUnit-TestH5S.txt > /dev/null; then echo " PASSED JUnit-TestH5S" else echo "**FAILED** JUnit-TestH5S" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5S.txt JUnit-TestH5S.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Tparams" @@ -518,7 +540,9 @@ if diff JUnit-TestH5Tparams.out JUnit-TestH5Tparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Tparams" else echo "**FAILED** JUnit-TestH5Tparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Tparams.txt JUnit-TestH5Tparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Tbasic" @@ -537,7 +561,9 @@ if diff JUnit-TestH5Tbasic.out JUnit-TestH5Tbasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Tbasic" else echo "**FAILED** JUnit-TestH5Tbasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Tbasic.txt JUnit-TestH5Tbasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5T" @@ -556,7 +582,9 @@ if diff JUnit-TestH5T.out JUnit-TestH5T.txt > /dev/null; then echo " PASSED JUnit-TestH5T" else echo "**FAILED** JUnit-TestH5T" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5T.txt JUnit-TestH5T.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Dparams" @@ -575,7 +603,9 @@ if diff JUnit-TestH5Dparams.out JUnit-TestH5Dparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Dparams" else echo "**FAILED** JUnit-TestH5Dparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Dparams.txt JUnit-TestH5Dparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5D" @@ -594,7 +624,9 @@ if diff JUnit-TestH5D.out JUnit-TestH5D.txt > /dev/null; then echo " PASSED JUnit-TestH5D" else echo "**FAILED** JUnit-TestH5D" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5D.txt JUnit-TestH5D.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Dplist" @@ -613,7 +645,9 @@ if diff JUnit-TestH5Dplist.out JUnit-TestH5Dplist.txt > /dev/null; then echo " PASSED JUnit-TestH5Dplist" else echo "**FAILED** JUnit-TestH5Dplist" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Dplist.txt JUnit-TestH5Dplist.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Lparams" @@ -632,7 +666,9 @@ if diff JUnit-TestH5Lparams.out JUnit-TestH5Lparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Lparams" else echo "**FAILED** JUnit-TestH5Lparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Lparams.txt JUnit-TestH5Lparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Lbasic" @@ -651,7 +687,9 @@ if diff JUnit-TestH5Lbasic.out JUnit-TestH5Lbasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Lbasic" else echo "**FAILED** JUnit-TestH5Lbasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Lbasic.txt JUnit-TestH5Lbasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Lcreate" @@ -670,7 +708,9 @@ if diff JUnit-TestH5Lcreate.out JUnit-TestH5Lcreate.txt > /dev/null; then echo " PASSED JUnit-TestH5Lcreate" else echo "**FAILED** JUnit-TestH5Lcreate" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Lcreate.txt JUnit-TestH5Lcreate.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5R" @@ -689,7 +729,9 @@ if diff JUnit-TestH5R.out JUnit-TestH5R.txt > /dev/null; then echo " PASSED JUnit-TestH5R" else echo "**FAILED** JUnit-TestH5R" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5R.txt JUnit-TestH5R.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5P" @@ -708,7 +750,9 @@ if diff JUnit-TestH5P.out JUnit-TestH5P.txt > /dev/null; then echo " PASSED JUnit-TestH5P" else echo "**FAILED** JUnit-TestH5P" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5P.txt JUnit-TestH5P.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5PData" @@ -727,7 +771,9 @@ if diff JUnit-TestH5PData.out JUnit-TestH5PData.txt > /dev/null; then echo " PASSED JUnit-TestH5PData" else echo "**FAILED** JUnit-TestH5PData" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5PData.txt JUnit-TestH5PData.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pfapl" @@ -746,7 +792,9 @@ if diff JUnit-TestH5Pfapl.out JUnit-TestH5Pfapl.txt > /dev/null; then echo " PASSED JUnit-TestH5Pfapl" else echo "**FAILED** JUnit-TestH5Pfapl" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Pfapl.txt JUnit-TestH5Pfapl.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Pvirtual" @@ -765,7 +813,9 @@ if diff JUnit-TestH5Pvirtual.out JUnit-TestH5Pvirtual.txt > /dev/null; then echo " PASSED JUnit-TestH5Pvirtual" else echo "**FAILED** JUnit-TestH5Pvirtual" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Pvirtual.txt JUnit-TestH5Pvirtual.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Plist" @@ -784,7 +834,9 @@ if diff JUnit-TestH5Plist.out JUnit-TestH5Plist.txt > /dev/null; then echo " PASSED JUnit-TestH5Plist" else echo "**FAILED** JUnit-TestH5Plist" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Plist.txt JUnit-TestH5Plist.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5A" @@ -803,7 +855,9 @@ if diff JUnit-TestH5A.out JUnit-TestH5A.txt > /dev/null; then echo " PASSED JUnit-TestH5A" else echo "**FAILED** JUnit-TestH5A" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5A.txt JUnit-TestH5A.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Oparams" @@ -822,7 +876,9 @@ if diff JUnit-TestH5Oparams.out JUnit-TestH5Oparams.txt > /dev/null; then echo " PASSED JUnit-TestH5Oparams" else echo "**FAILED** JUnit-TestH5Oparams" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Oparams.txt JUnit-TestH5Oparams.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Obasic" @@ -841,7 +897,9 @@ if diff JUnit-TestH5Obasic.out JUnit-TestH5Obasic.txt > /dev/null; then echo " PASSED JUnit-TestH5Obasic" else echo "**FAILED** JUnit-TestH5Obasic" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Obasic.txt JUnit-TestH5Obasic.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Ocreate" @@ -860,7 +918,9 @@ if diff JUnit-TestH5Ocreate.out JUnit-TestH5Ocreate.txt > /dev/null; then echo " PASSED JUnit-TestH5Ocreate" else echo "**FAILED** JUnit-TestH5Ocreate" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Ocreate.txt JUnit-TestH5Ocreate.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Ocopy" @@ -879,7 +939,9 @@ if diff JUnit-TestH5Ocopy.out JUnit-TestH5Ocopy.txt > /dev/null; then echo " PASSED JUnit-TestH5Ocopy" else echo "**FAILED** JUnit-TestH5Ocopy" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Ocopy.txt JUnit-TestH5Ocopy.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5PL" @@ -898,7 +960,9 @@ if diff JUnit-TestH5PL.out JUnit-TestH5PL.txt > /dev/null; then echo " PASSED JUnit-TestH5PL" else echo "**FAILED** JUnit-TestH5PL" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5PL.txt JUnit-TestH5PL.out |sed 's/^/ /' fi echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z" @@ -917,7 +981,9 @@ if diff JUnit-TestH5Z.out JUnit-TestH5Z.txt > /dev/null; then echo " PASSED JUnit-TestH5Z" else echo "**FAILED** JUnit-TestH5Z" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Z.txt JUnit-TestH5Z.out |sed 's/^/ /' fi if test "X-$BUILD_MODE" = "X-production" ; then @@ -938,7 +1004,9 @@ if test "X-$BUILD_MODE" = "X-production" ; then echo " PASSED JUnit-TestH5E" else echo "**FAILED** JUnit-TestH5E" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5E.txt JUnit-TestH5E.out |sed 's/^/ /' fi fi @@ -959,7 +1027,9 @@ if test "X-$BUILD_MODE" = "X-production" ; then echo " PASSED JUnit-TestH5Edefault" else echo "**FAILED** JUnit-TestH5Edefault" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Edefault.txt JUnit-TestH5Edefault.out |sed 's/^/ /' fi fi fi @@ -980,7 +1050,9 @@ if test $USE_FILTER_SZIP = "yes"; then echo " PASSED JUnit-TestH5Giterate" else echo "**FAILED** JUnit-TestH5Giterate" + echo " Expected result differs from actual result" nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5Giterate.txt JUnit-TestH5Giterate.out |sed 's/^/ /' fi fi diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index a2d209a..a5864be 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -12,7 +12,6 @@ Section IV: Further considerations Section V: Options for building HDF5 Libraries with CMake command line Section VI: CMake option defaults for HDF5 Section VII: User Defined Options for HDF5 Libraries with CMake -Section VIII: Options for platform configuration files ************************************************************************ @@ -35,7 +34,8 @@ CMake version Note: To change the install prefix from the platform defaults initialize - the CMake variable, CMAKE_INSTALL_PREFIX. + the CMake variable, CMAKE_INSTALL_PREFIX. Users of build scripts + will use the INSTALLDIR option. ======================================================================== @@ -89,14 +89,14 @@ To build HDF5 with the SZIP and ZLIB external libraries you will need to: 5. From the "myhdfstuff" directory execute the CTest Script with the following options: + On 32-bit Windows with Visual Studio 2017, execute: + ctest -S HDF5config.cmake,BUILD_GENERATOR=VS2017 -C Release -VV -O hdf5.log + On 64-bit Windows with Visual Studio 2017, execute: + ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log On 32-bit Windows with Visual Studio 2015, execute: ctest -S HDF5config.cmake,BUILD_GENERATOR=VS2015 -C Release -VV -O hdf5.log On 64-bit Windows with Visual Studio 2015, execute: ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201564 -C Release -VV -O hdf5.log - On 32-bit Windows with Visual Studio 2013, execute: - ctest -S HDF5config.cmake,BUILD_GENERATOR=VS2013 -C Release -VV -O hdf5.log - On 64-bit Windows with Visual Studio 2013, execute: - ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201364 -C Release -VV -O hdf5.log On Linux and Mac, execute: ctest -S HDF5config.cmake,BUILD_GENERATOR=Unix -C Release -VV -O hdf5.log The supplied build scripts are versions of the above. @@ -167,6 +167,14 @@ To build HDF5 with the SZIP and ZLIB external libraries you will need to: By default the installation will create the bin, include, lib and cmake folders in the <install destination directory>/HDF_Group/HDF5/1.10."X" + The <install destination directory> depends on the build platform; + Windows will set the default to: + C:/Program Files/HDF_Group/HDF5/1.10."X" + Linux will set the default to: + "myhdfstuff/HDF_Group/HDF5/1.10."X" + The default can be changed by adding ",INSTALLDIR=<my new dir>" to the + "ctest -S HDF5config.cmake..." command. For example on linux: + ctest -S HDF5config.cmake,INSTALLDIR=/usr/local/myhdf5,BUILD_GENERATOR=Unix -C Release -VV -O hdf5.log ======================================================================== @@ -651,332 +659,6 @@ UserMacros.cmake file. Then enable the option to the CMake configuration, build and test process. ======================================================================== -VIII. Options for Platform Configuration Files -======================================================================== - -Below is the HDF5config.cmake and HDF5options.cmake ctest scripts. -Execute: - ctest -S HDF5config.cmake,BUILD_GENERATOR=xxx -C Release -VV -O hdf5.log -The same scripts can be used on Linux, Mac OSX or a Windows machine by -adding an option (${CTEST_SCRIPT_ARG}) to the platform configuration script. - - -############################################################################################# -### ${CTEST_SCRIPT_ARG} is of the form OPTION=VALUE ### -### BUILD_GENERATOR required [Unix, VS2017, VS201764, VS2015, VS201564, VS2013, VS201364] ### -### ctest -S HDF5config.cmake,BUILD_GENERATOR=VS201764 -C Release -VV -O hdf5.log ### -############################################################################################# - -cmake_minimum_required (VERSION 3.10) -############################################################################ -# Usage: -# ctest -S HDF5config.cmake,OPTION=VALUE -C Release -VV -O test.log -# where valid options for OPTION are: -# BUILD_GENERATOR - The cmake build generator: -# Unix * Unix Makefiles -# VS2017 * Visual Studio 15 2017 -# VS201764 * Visual Studio 15 2017 Win64 -# VS2015 * Visual Studio 14 2015 -# VS201564 * Visual Studio 14 2015 Win64 -# VS2013 * Visual Studio 12 2013 -# VS201364 * Visual Studio 12 2013 Win64 -# -# INSTALLDIR - root folder where hdf5 is installed -# CTEST_CONFIGURATION_TYPE - Release, Debug, etc -# CTEST_SOURCE_NAME - source folder -############################################################################## - -set (CTEST_SOURCE_VERSION "1.11.0") -set (CTEST_SOURCE_VERSEXT "") - -############################################################################## -# handle input parameters to script. -#BUILD_GENERATOR - which CMake generator to use, required -#INSTALLDIR - HDF5-1.10.0 root folder -#CTEST_CONFIGURATION_TYPE - Release, Debug, RelWithDebInfo -#CTEST_SOURCE_NAME - name of source folder; HDF5-1.10.0 -if (DEFINED CTEST_SCRIPT_ARG) - # transform ctest script arguments of the form - # script.ctest,var1=value1,var2=value2 - # to variables with the respective names set to the respective values - string (REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") - foreach (current_var ${script_args}) - if ("${current_var}" MATCHES "^([^=]+)=(.+)$") - set ("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") - endif () - endforeach () -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") -endif () - -################################################################### -### Following Line is one of [Release, RelWithDebInfo, Debug] ##### -set (CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") -################################################################### - -if (NOT DEFINED INSTALLDIR) - if (WIN32) - set (INSTALLDIR "C:/Program Files/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") - else () - set (INSTALLDIR "${CTEST_SCRIPT_DIRECTORY}/HDF_Group/HDF5/${CTEST_SOURCE_VERSION}") - endif () -endif () -if (NOT DEFINED CTEST_CONFIGURATION_TYPE) - set (CTEST_CONFIGURATION_TYPE "Release") -endif () -if (NOT DEFINED CTEST_SOURCE_NAME) - set (CTEST_SOURCE_NAME "hdf5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") -endif () -if (NOT DEFINED STATIC_ONLY) - set (STATICONLYLIBRARIES "YES") -else () - set (STATICONLYLIBRARIES "NO") -endif () -if (NOT DEFINED FORTRAN_LIBRARIES) - set (FORTRANLIBRARIES "NO") -else () - set(FORTRANLIBRARIES "YES") -endif () -if (NOT DEFINED JAVA_LIBRARIES) - set (JAVALIBRARIES "NO") -else () - set (JAVALIBRARIES "YES") -endif () - -set (CTEST_BINARY_NAME "build") -set (CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") -if (WIN32) - set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") - set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") -else () - set (CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") - set (CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") -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") - 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 () - 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 () -################################################################### - -################################################################### -######### Following is for submission to CDash ############ -################################################################### -set (MODEL "Experimental") -################################################################### - -################################################################### -##### Following controls CDash submission ##### -#set (LOCAL_SUBMIT "TRUE") -##### Following controls test process ##### -#set (LOCAL_SKIP_TEST "TRUE") -#set (LOCAL_MEMCHECK_TEST "TRUE") -#set (LOCAL_COVERAGE_TEST "TRUE") -##### Following controls cpack command ##### -#set (LOCAL_NO_PACKAGE "TRUE") -##### Following controls source update ##### -#set (LOCAL_UPDATE "TRUE") -set (REPOSITORY_URL "https://git@bitbucket.hdfgroup.org/scm/hdffv/hdf5.git") -set (REPOSITORY_BRANCH "develop") - -#uncomment to use a compressed source file: *.tar on linux or mac *.zip on windows -#set(CTEST_USE_TAR_SOURCE "${CTEST_SOURCE_VERSION}") -################################################################### - -################################################################### -if (${STATICONLYLIBRARIES}) - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") - ######### Following describes computer ############ - ## following is optional to describe build ## - set (SITE_BUILDNAME_SUFFIX "STATIC") -endif () -################################################################### -#### fortran #### -if (${FORTRANLIBRARIES}) - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON") - ### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=ON") -else () - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") - ### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=OFF") -endif () -#### java #### -if (${JAVALIBRARIES}) - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=ON") -else () - set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_JAVA:BOOL=OFF") -endif () - -### change install prefix -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=${INSTALLDIR}") -set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCTEST_CONFIGURATION_TYPE:STRING=$ENV{CMAKE_CONFIG_TYPE}") - -################################################################### - -if (WIN32) - set (BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}") - include (${CTEST_SCRIPT_DIRECTORY}\\HDF5options.cmake) - include (${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) - if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe") - file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.exe" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi") - file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.msi" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip") - file (COPY "${CTEST_BINARY_DIRECTORY}\\${BINFILEBASE}.zip" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () -else () - set (BINFILEBASE "HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") - include (${CTEST_SCRIPT_DIRECTORY}/HDF5options.cmake) - include (${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) - if (APPLE) - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.dmg" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Darwin.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - else () - if (CYGWIN) - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-CYGWIN.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - else () - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - if (EXISTS "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz") - file (COPY "${CTEST_BINARY_DIRECTORY}/${BINFILEBASE}-Linux.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif () - endif () - endif () -endif () - -HDF5options.cmake: -############################################################################################# -#### 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 - -############################################################################################# -#### alternate toolsets #### -#set(CMAKE_GENERATOR_TOOLSET "Intel C++ Compiler 17.0") - -############################################################################################# -#### 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} -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 ext zlib building -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") -### disable ext szip building -#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") - -############################################################################################# -### 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") - -############################################################################################# - -======================================================================== For further assistance, send email to help@hdfgroup.org ======================================================================== diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 1204c0b..a322164 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -67,7 +67,13 @@ New Features Java Library: ---------------- - - + - JNI Read and Write + + Refactored variable-length functions, H5DreadVL and H5AreadVL, + to correct dataset and attribute reads. New write functions, + H5DwriteVL and H5AwriteVL, are under construction. + + (ADB - 2018/06/02, HDFFV10519) Tools: ------ diff --git a/release_docs/USING_CMake_Examples.txt b/release_docs/USING_CMake_Examples.txt index f188ab3..6f744d9 100644 --- a/release_docs/USING_CMake_Examples.txt +++ b/release_docs/USING_CMake_Examples.txt @@ -48,6 +48,8 @@ Default installation process: with the CTEST_SOURCE_NAME script option. The default installation folder is defined as "@CMAKE_INSTALL_PREFIX@". It can be changed with the INSTALLDIR script option. + (Note: Windows has issues with spaces and paths -The path will need to + be set correctly.) The default ctest configuration is defined as "Release". It can be changed with the CTEST_CONFIGURATION_TYPE script option. Note that this must be the same as the value used with the -C command line option. diff --git a/release_docs/USING_HDF5_CMake.txt b/release_docs/USING_HDF5_CMake.txt index 7d9a585..73a24d9 100644 --- a/release_docs/USING_HDF5_CMake.txt +++ b/release_docs/USING_HDF5_CMake.txt @@ -225,232 +225,6 @@ Also available at the HDF web site is a CMake application framework template. You can quickly add files to the framework and execute the script to compile your application with an installed HDF5 binary. -======================================================================== -ctest use of HDF5_Examples.cmake and HDF5_Examples_options.cmake -======================================================================== - -cmake_minimum_required (VERSION 3.10) -############################################################################################################### -# This script will build and run the examples from a folder -# Execute from a command line: -# ctest -S HDF5_Examples.cmake,OPTION=VALUE -C Release -VV -O test.log -############################################################################################################### - -set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -if("@CMAKE_GENERATOR_TOOLSET@") - set(CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@") -endif() -set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) - -# handle input parameters to script. -#INSTALLDIR - HDF5 root folder -#CTEST_CONFIGURATION_TYPE - Release, Debug, RelWithDebInfo -#CTEST_SOURCE_NAME - name of source folder; HDF5Examples -if(DEFINED CTEST_SCRIPT_ARG) - # transform ctest script arguments of the form - # script.ctest,var1=value1,var2=value2 - # to variables with the respective names set to the respective values - string(REPLACE "," ";" script_args "${CTEST_SCRIPT_ARG}") - foreach(current_var ${script_args}) - if("${current_var}" MATCHES "^([^=]+)=(.+)$") - set("${CMAKE_MATCH_1}" "${CMAKE_MATCH_2}") - endif() - endforeach() -endif() - -################################################################### -### Following Line is one of [Release, RelWithDebInfo, Debug] ##### -set(CTEST_CONFIGURATION_TYPE "$ENV{CMAKE_CONFIG_TYPE}") -if(NOT DEFINED CTEST_CONFIGURATION_TYPE) - set(CTEST_CONFIGURATION_TYPE "Release") -endif() -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCTEST_CONFIGURATION_TYPE:STRING=${CTEST_CONFIGURATION_TYPE}") -################################################################## - -if(NOT DEFINED INSTALLDIR) - set(INSTALLDIR "@CMAKE_INSTALL_PREFIX@") -endif() - -if(NOT DEFINED CTEST_SOURCE_NAME) - set(CTEST_SOURCE_NAME "HDF5Examples") -endif() - -if(NOT DEFINED HDF_LOCAL) - set(CDASH_LOCAL "NO") -else() - set(CDASH_LOCAL "YES") -endif() -if(NOT DEFINED CTEST_SITE) - set(CTEST_SITE "local") -endif() -if(NOT DEFINED CTEST_BUILD_NAME) - set(CTEST_BUILD_NAME "examples") -endif() -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") - -#TAR_SOURCE - name of tarfile -#if(NOT DEFINED TAR_SOURCE) -# set(CTEST_USE_TAR_SOURCE "HDF5Examples-1.10.7-Source") -#endif() - -############################################################################################################### -if(WIN32) - set(SITE_OS_NAME "Windows") - set(ENV{HDF5_DIR} "${INSTALLDIR}/cmake") - set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}\\build) - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") -else() - set(ENV{HDF5_DIR} "${INSTALLDIR}/share/cmake") - set(ENV{LD_LIBRARY_PATH} "${INSTALLDIR}/lib") - set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}/build) - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") -endif() -if(${CDASH_LOCAL}) - set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCDASH_LOCAL:BOOL=ON") -endif() -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_NAME:STRING=@HDF5_PACKAGE@@HDF_PACKAGE_EXT@") - -############################################################################################################### -# For any comments please contact help@hdfgroup.org -# -############################################################################################################### - -############################################################################################# -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -#### format for file: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### -############################################################################################# -if(WIN32) - include(${CTEST_SCRIPT_DIRECTORY}\\HDF5_Examples_options.cmake) -else() - include(${CTEST_SCRIPT_DIRECTORY}/HDF5_Examples_options.cmake) -endif() - -#----------------------------------------------------------------------------- -set (CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") -## -------------------------- -if (CTEST_USE_TAR_SOURCE) - ## Uncompress source if tar or zip file provided - ## -------------------------- - if (WIN32) - message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip]") - execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) - else () - message (STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") - execute_process (COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) - endif () - - if (NOT rv EQUAL 0) - message (STATUS "extracting... [error-(${rv}) clean up]") - file (REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") - message (FATAL_ERROR "error: extract of ${CTEST_SOURCE_NAME} failed") - endif () -endif () - -#----------------------------------------------------------------------------- -## Clear the build directory -## -------------------------- -set (CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) -if (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") - ctest_empty_binary_directory (${CTEST_BINARY_DIRECTORY}) -else () - file (MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") -endif () - -# Use multiple CPU cores to build -include (ProcessorCount) -ProcessorCount (N) -if (NOT N EQUAL 0) - if (NOT WIN32) - set (CTEST_BUILD_FLAGS -j${N}) - endif () - set (ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) -endif () -set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" -) - -#----------------------------------------------------------------------------- -## -- set output to english -set ($ENV{LC_MESSAGES} "en_EN") - -#----------------------------------------------------------------------------- -configure_file (${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) -ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") -## NORMAL process -## -------------------------- -ctest_start (Experimental) -ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}") -if (LOCAL_SUBMIT) - ctest_submit (PARTS Configure Notes) -endif () -ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) -if (LOCAL_SUBMIT) - ctest_submit (PARTS Build) -endif () -ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) -if (LOCAL_SUBMIT) - ctest_submit (PARTS Test) -endif () -if (res GREATER 0) - message (FATAL_ERROR "tests FAILED") -endif () -#----------------------------------------------------------------------------- -############################################################################################################## - -############################################################################################################## -#### HDF5_Examples_options.cmake ### -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -############################################################################################################## -############################################################################################# -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") ### -#### DEFAULT: ### -#### BUILD_SHARED_LIBS:BOOL=OFF ### -#### HDF_BUILD_C:BOOL=ON ### -#### HDF_BUILD_CXX:BOOL=OFF ### -#### HDF_BUILD_FORTRAN:BOOL=OFF ### -#### HDF_BUILD_JAVA:BOOL=OFF ### -#### BUILD_TESTING:BOOL=OFF ### -#### HDF_ENABLE_PARALLEL:BOOL=OFF ### -#### HDF_ENABLE_THREADSAFE:BOOL=OFF ### -############################################################################################# - -### uncomment/comment and change the following lines for other configuration options -### build with shared libraries -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=ON") - -############################################################################################# -#### languages #### -### disable C builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_C:BOOL=OFF") - -### enable C++ builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_CXX:BOOL=ON") - -### enable Fortran builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") - -### enable JAVA builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_BUILD_JAVA:BOOL=ON") - -############################################################################################# -### enable parallel program builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_ENABLE_PARALLEL:BOOL=ON") - -############################################################################################# -### enable threadsafe program builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF_ENABLE_THREADSAFE:BOOL=ON") - -############################################################################################# -### enable test program builds, requires reference files in testfiles subdirectory -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=ON") -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCOMPARE_TESTING:BOOL=ON") - -############################################################################################# - - ======================================================================== For further assistance, send email to help@hdfgroup.org @@ -700,7 +700,7 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if(NULL == (new_file = H5F__new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") /* Duplicate old file's names */ diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 487ed2f..07bb644 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -73,7 +73,7 @@ H5FL_DEFINE_STATIC(H5F_efc_t); /*------------------------------------------------------------------------- - * Function: H5F_efc_create + * Function: H5F__efc_create * * Purpose: Allocate and initialize a new external file cache object, * which can the be used to cache open external files. @@ -88,12 +88,12 @@ H5FL_DEFINE_STATIC(H5F_efc_t); *------------------------------------------------------------------------- */ H5F_efc_t * -H5F_efc_create(unsigned max_nfiles) +H5F__efc_create(unsigned max_nfiles) { H5F_efc_t *efc = NULL; /* EFC object */ H5F_efc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(max_nfiles > 0); @@ -116,7 +116,7 @@ done: efc = H5FL_FREE(H5F_efc_t, efc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_efc_create() */ +} /* end H5F__efc_create() */ /*------------------------------------------------------------------------- @@ -139,8 +139,7 @@ done: *------------------------------------------------------------------------- */ H5F_t * -H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id) +H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_efc_t *efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ @@ -376,7 +375,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_efc_max_nfiles + * Function: H5F__efc_max_nfiles * * Purpose: Returns the maximum number of files in the provided * external file cache. @@ -389,15 +388,15 @@ done: *------------------------------------------------------------------------- */ unsigned -H5F_efc_max_nfiles(H5F_efc_t *efc) +H5F__efc_max_nfiles(H5F_efc_t *efc) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(efc); HDassert(efc->max_nfiles > 0); FUNC_LEAVE_NOAPI(efc->max_nfiles) -} /* end H5F_efc_max_nfiles */ +} /* end H5F__efc_max_nfiles */ /*------------------------------------------------------------------------- @@ -793,7 +792,7 @@ H5F__efc_try_close_tag2(H5F_file_t *sf, H5F_file_t **tail) * uncloseable file would be closed. * * The final pass exploits the H5F__efc_release_real()-> - * H5F_efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() + * H5F__efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() * calling chain to recursively close the tree, but only the * files that are still marked as closeable. All files * marked as closeable have their EFCs released, and will @@ -819,7 +818,7 @@ H5F__efc_try_close(H5F_t *f) H5F_file_t *next; /* Temporary file pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(f); @@ -852,7 +851,7 @@ H5F__efc_try_close(H5F_t *f) /* If there are references that are not from an EFC or f, it will never * be possible to close the file. Just return. Note that this holds true * for the case that this file is being closed through H5F__efc_release_real() - * because that function (through H5F_efc_remove_ent()) decrements the EFC + * because that function (through H5F__efc_remove_ent()) decrements the EFC * reference count before it calls H5F_try_close(). This may occur if this * function is reentered. */ /* If the tag is H5F_EFC_TAG_DONTCLOSE, then we have definitely reentered diff --git a/src/H5Fint.c b/src/H5Fint.c index 7d71fbc..abc638a 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -21,22 +21,22 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -74,11 +74,9 @@ typedef struct H5F_olist_t { /********************/ static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F__build_name(const char *prefix, const char *file_name, - char **full_name/*out*/); +static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); -static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ +static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -175,7 +173,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") if(f->shared->efc) - efc_size = H5F_efc_max_nfiles(f->shared->efc); + efc_size = H5F__efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") if(f->shared->page_buf != NULL) { @@ -486,11 +484,12 @@ done: /*-------------------------------------------------------------------------- - * Function: H5F__build_name + * Function: H5F__build_name * - * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure *--------------------------------------------------------------------------*/ static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) @@ -818,34 +817,37 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_new + * Function: H5F__new * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various fields. - * If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL * - * Return: Success: Ptr to a new file struct. - * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * -H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->file_id = H5I_INVALID_HID; if(shared) { HDassert(lf == NULL); f->shared = shared; - } /* end if */ + } else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ @@ -866,7 +868,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; f->shared->fs_addr[u] = HADDR_UNDEF; f->shared->fs_man[u] = NULL; - } /* end for */ + } f->shared->first_alloc_dealloc = FALSE; f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; @@ -878,9 +880,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t /* intialize point of no return */ f->shared->point_of_no_return = FALSE; - /* - * Copy the file creation and file access property lists into the - * new file handle. We do this early because some values might need + /* Copy the file creation and file access property lists into the + * new file handle. We do this early because some values might need * to change as the file is being opened. */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) @@ -906,7 +907,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation - when persisting free-space or using paged aggregation strategy */ + * when persisting free-space or using paged aggregation strategy. + */ if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") @@ -947,7 +949,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") if(efc_size > 0) - if(NULL == (f->shared->efc = H5F_efc_create(efc_size))) + if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) @@ -1000,12 +1002,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } /* end if */ + } else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } /* end else */ + } /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1031,8 +1033,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") - /* - * Create a metadata cache with the specified number of elements. + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ @@ -1069,12 +1070,12 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_file_t, f->shared); - } /* end if */ + } f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_new() */ +} /* end H5F__new() */ /*------------------------------------------------------------------------- @@ -1587,7 +1588,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1615,7 +1616,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) { + if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct * returned is NULL, H5FD_close() will never be called via H5F_dest() * so we have to close lf here before heading to the error handling. @@ -2085,7 +2086,7 @@ H5F__close_cb(H5F_t *f) unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2150,7 +2151,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) } /* end if */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e3a92fd..4cd1edf 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -15,21 +15,18 @@ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* PRIVATE PROTOTYPES */ -static herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, - hid_t plist_id); -static herr_t H5F__unmount(H5G_loc_t *loc, const char *name); -static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /*------------------------------------------------------------------------- @@ -47,16 +44,17 @@ static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigne herr_t H5F__close_mounts(H5F_t *f) { - unsigned u; /* Local index */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(f); /* Unmount all child files. Loop backwards to avoid having to adjust u when * a file is unmounted. Note that we rely on unsigned u "wrapping around" - * to terminate the loop. */ + * to terminate the loop. + */ for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) { /* Only unmount children mounted to this top level file structure */ if(f->shared->mtab.child[u].file->parent == f) { @@ -77,7 +75,7 @@ H5F__close_mounts(H5F_t *f) f->shared->mtab.nmounts--; f->nmounts--; } - } /* end if */ + } HDassert(f->nmounts == 0); @@ -100,7 +98,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { H5G_t *mount_point = NULL; /*mount point group */ @@ -112,9 +110,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ H5G_loc_t root_loc; /* Group location of root of file to mount */ - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -162,9 +160,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); for(ancestor = parent; ancestor; ancestor = ancestor->parent) { - if(ancestor->shared == child->shared) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") - } /* end for */ + if(ancestor->shared == child->shared) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") + } /* Make certain that the parent & child files have the same "file close degree" */ if(parent->shared->fc_degree != child->shared->fc_degree) @@ -181,29 +179,29 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED while(lt < rt && cmp) { H5O_loc_t *oloc; /*temporary symbol table entry */ - md = (lt + rt) / 2; - oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); - if(cmp < 0) - rt = md; - else if(cmp > 0) - lt = md + 1; - } /* end while */ + md = (lt + rt) / 2; + oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); + if(cmp < 0) + rt = md; + else if(cmp > 0) + lt = md + 1; + } if(cmp > 0) md++; if(!cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { - unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); - H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); + unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); + H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); - if(!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->shared->mtab.child = x; - parent->shared->mtab.nalloc = n; - } /* end if */ + if(!x) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") + parent->shared->mtab.child = x; + parent->shared->mtab.nalloc = n; + } /* Insert into table */ HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, @@ -228,19 +226,19 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED /* We pass H5G_UNKNOWN as object type; search all IDs */ if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: if(ret_value < 0) { if(mount_point) { if(H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") - } /* end if */ + } else { if(H5G_loc_free(&mp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") - } /* end else */ - } /* end if */ + } + } FUNC_LEAVE_NOAPI_VOL(ret_value) } /* end H5F__mount() */ @@ -264,7 +262,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__unmount(H5G_loc_t *loc, const char *name) { H5G_t *child_group = NULL; /* Child's group in parent mtab */ @@ -279,7 +277,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -304,41 +302,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name) if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { unsigned u; /*counters */ - /* - * We've been given the root group of the child. We do a reverse - * lookup in the parent's mount table to find the correct entry. - */ - parent = child->parent; - for(u = 0; u < parent->shared->mtab.nmounts; u++) { - if(parent->shared->mtab.child[u].file->shared == child->shared) { + /* + * We've been given the root group of the child. We do a reverse + * lookup in the parent's mount table to find the correct entry. + */ + parent = child->parent; + for(u = 0; u < parent->shared->mtab.nmounts; u++) { + if(parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ child_idx = (int)u; break; - } /* end if */ - } /* end for */ - } else { + } + } + } + else { unsigned lt, rt, md = 0; /*binary search indices */ int cmp; /*binary search comparison value*/ - /* - * We've been given the mount point in the parent. We use a binary - * search in the parent to locate the mounted file, if any. - */ - parent = child; /*we guessed wrong*/ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); - if (cmp<0) - rt = md; - else - lt = md + 1; - } /* end while */ - if(cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") + /* We've been given the mount point in the parent. We use a binary + * search in the parent to locate the mounted file, if any. + */ + parent = child; /*we guessed wrong*/ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); + if (cmp<0) + rt = md; + else + lt = md + 1; + } + + if(cmp) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ child_idx = (int)md; @@ -426,48 +426,59 @@ H5F_is_mount(const H5F_t *file) /*------------------------------------------------------------------------- - * Function: H5Fmount + * Function: H5Fmount * - * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and - * NAME using mount properties PLIST_ID. + * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and + * NAME using mount properties PLIST_ID. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; - H5F_t *child = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5F_t *child = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") + child_type = H5I_get_type(child_id); + if(H5I_FILE != child_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a property list ID") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Do the mount */ + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Get the child object */ + if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + + /* Perform the mount operation */ if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) @@ -475,46 +486,51 @@ done: /*------------------------------------------------------------------------- - * Function: H5Funmount - * - * Purpose: Given a mount point, dissassociate the mount point's file - * from the file mounted there. Do not close either file. + * Function: H5Funmount * - * The mount point can either be the group in the parent or the - * root group of the mounted file (both groups have the same - * name). If the mount point was opened before the mount then - * it's the group in the parent, but if it was opened after the - * mount then it's the root group of the child. + * Purpose: Given a mount point, dissassociate the mount point's file + * from the file mounted there. Do not close either file. * - * Return: Non-negative on success/Negative on failure + * The mount point can either be the group in the parent or the + * root group of the mounted file (both groups have the same + * name). If the mount point was opened before the mount then + * it's the group in the parent, but if it was opened after the + * mount then it's the root group of the child. * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; - herr_t ret_value=SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Unmount */ + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Perform the unmount operation */ if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) @@ -522,12 +538,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids_recurse + * Function: H5F__mount_count_ids_recurse * - * Purpose: Helper routine for counting number of open IDs in mount + * Purpose: Helper routine for counting number of open IDs in mount * hierarchy. * - * Return: <none> + * Return: void * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 @@ -535,11 +551,11 @@ done: *------------------------------------------------------------------------- */ static void -H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { unsigned u; /* Local index value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -564,20 +580,20 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) *nopen_objs += 1; - H5F_mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); } - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID -} /* end H5F_mount_count_ids_recurse() */ +} /* end H5F__mount_count_ids_recurse() */ /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids + * Function: H5F__mount_count_ids * - * Purpose: Count the number of open file & object IDs in a mount hierarchy + * Purpose: Count the number of open file & object IDs in a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tues, July 19, 2005 @@ -585,9 +601,9 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj *------------------------------------------------------------------------- */ herr_t -H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(f); @@ -599,10 +615,10 @@ H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) f = f->parent; /* Count open IDs in the hierarchy */ - H5F_mount_count_ids_recurse(f, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f, nopen_files, nopen_objs); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5F_mount_count_ids() */ +} /* end H5F__mount_count_ids() */ /*------------------------------------------------------------------------- @@ -648,11 +664,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_flush_mounts + * Function: H5F_flush_mounts * - * Purpose: Flush a mount hierarchy + * Purpose: Flush a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Fri, August 21, 2009 @@ -715,22 +731,22 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) * of file2, which is mounted somewhere in file3. */ do { - /* - * Use a binary search to find the potential mount point in the mount - * table for the parent - */ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); - if(cmp < 0) - rt = md; - else - lt = md + 1; - } /* end while */ + /* + * Use a binary search to find the potential mount point in the mount + * table for the parent + */ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); + if(cmp < 0) + rt = md; + else + lt = md + 1; + } /* Copy root info over to ENT */ if(0 == cmp) { diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 050e426..f815005 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -30,18 +30,18 @@ #include "H5Fprivate.h" /* Other public headers needed by this file */ -#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ +#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5PBprivate.h" /* Page buffer */ -#include "H5UCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ +#include "H5UCprivate.h" /* Reference counted object functions */ /* @@ -394,13 +394,10 @@ H5FL_EXTERN(H5F_file_t); /******************************/ /* General routines */ -H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, H5FD_t *lf); +H5_DLL H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); -H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); -H5_DLL H5F_t * H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t *H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F__flush(H5F_t *f, H5F_scope_t scope); H5_DLL herr_t H5F__flush_real(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name); @@ -408,8 +405,7 @@ H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, H5_DLL herr_t H5F__get_freespace(H5F_t *f, hsize_t *tot_space); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, - size_t nsects, H5F_sect_info_t *sect_info); +H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); H5_DLL herr_t H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info); H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); @@ -418,9 +414,10 @@ H5_DLL herr_t H5F__close_cb(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); /* File mount related routines */ +H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); +H5_DLL herr_t H5F__unmount(H5G_loc_t *loc, const char *name); H5_DLL herr_t H5F__close_mounts(H5F_t *f); -H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); -H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +H5_DLL herr_t H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /* Superblock related routines */ H5_DLL herr_t H5F__super_init(H5F_t *f); @@ -430,18 +427,14 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, - hbool_t may_create, unsigned mesg_flags); +H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags); H5_DLL herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id); H5_DLL herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created); /* Metadata accumulator routines */ -H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); -H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size); +H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); +H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); H5_DLL herr_t H5F__accum_flush(H5F_t *f); H5_DLL herr_t H5F__accum_reset(H5F_t *f, hbool_t flush); @@ -451,10 +444,9 @@ H5_DLL H5F_file_t * H5F_sfile_search(H5FD_t *lf); H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); /* External file cache routines */ -H5_DLL H5F_efc_t *H5F_efc_create(unsigned max_nfiles); -H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, - hid_t fcpl_id, hid_t fapl_id); -H5_DLL unsigned H5F_efc_max_nfiles(H5F_efc_t *efc); +H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); +H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_try_close(H5F_t *f); @@ -462,8 +454,7 @@ H5_DLL herr_t H5F__efc_try_close(H5F_t *f); /* Space allocation routines */ H5_DLL haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, - hsize_t extra_requested); +H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); @@ -476,8 +467,7 @@ H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f); /* Testing functions */ #ifdef H5F_TESTING -H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, - size_t *mesg_count); +H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id); H5_DLL herr_t H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); H5_DLL herr_t H5F_get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 3e77700..f06d4d0 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -296,7 +296,7 @@ typedef struct H5F_t H5F_t; #define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) #define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) #define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) -#define H5F_NREFS(F) ((F)->shared->nrefs) +#define H5F_NREFS(F) ((F)->shared->nrefs) #define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) #define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) @@ -713,8 +713,7 @@ typedef enum H5F_prefix_open_t { /***************************************/ /* Private functions */ -H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); H5_DLL herr_t H5F_start_swmr_write(H5F_t *file); @@ -795,10 +794,8 @@ H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); H5_DLL herr_t H5F_flush_mounts(H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf/*out*/); -H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); +H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Functions that flush or evict */ H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag); @@ -851,8 +848,7 @@ H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); H5_DLL herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr); -H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, - hbool_t add_heap); +H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t add_heap); H5_DLL herr_t H5F_cwfs_remove_heap(H5F_file_t *shared, struct H5HG_heap_t *heap); /* Debugging functions */ @@ -75,16 +75,16 @@ typedef struct { } H5I_id_type_t; typedef struct { - H5I_search_func_t app_cb; /* Application's callback routine */ - void *app_key; /* Application's "key" (user data) */ - void *ret_obj; /* Object to return */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void *app_key; /* Application's "key" (user data) */ + void *ret_obj; /* Object to return */ } H5I_search_ud_t; /* User data for iterator callback for ID iteration */ typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void *user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_search_func_t user_func; /* 'User' function to invoke */ + void *user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ @@ -126,26 +126,26 @@ static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); static int H5I__inc_type_ref(H5I_type_t type); static int H5I__get_type_ref(H5I_type_t type); +static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); static ssize_t H5I__get_name(const H5G_loc_t *loc, char *name, size_t size); #ifdef H5I_DEBUG_OUTPUT +static int H5I__debug_cb(void *_item, void *_key, void *_udata); static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ /*------------------------------------------------------------------------- - * Function: H5I_term_package + * Function: H5I_term_package * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. * - * Failure: Negative. - * - * Programmer: Unknown + * Failure: Negative. * *------------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) } /* end else */ /* Allocate new ID class */ - if(NULL == (cls = H5FL_MALLOC(H5I_class_t))) + if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ @@ -333,8 +333,7 @@ done: * Purpose: Query function to inform the user if a given type is * currently registered with the library. * - * Return: Success: 1 if the type is registered, 0 if it is not - * Failure: Negative + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -358,15 +357,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Inmembers + * Function: H5Inmembers * - * Purpose: Returns the number of members in a type. Public interface to - * H5I_nmembers. The public interface throws an error if the + * Purpose: Returns the number of members in a type. Public interface to + * H5I_nmembers. The public interface throws an error if the * supplied type does not exist. This is different than the * private interface, which will just return 0. * - * Return: Success: Zero - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -409,14 +407,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_nmembers + * Function: H5I_nmembers * - * Purpose: Returns the number of members in a type. + * Purpose: Returns the number of members in a type. * - * Return: Success: Number of members; zero if the type is empty - * or has been deleted. + * Return: Success: Number of members; zero if the type is empty + * or has been deleted. * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -445,14 +443,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iclear_type + * Function: H5Iclear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. - * Public interface to H5I_clear_type. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. + * Public interface to H5I_clear_type. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -479,13 +476,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_clear_type + * Function: H5I_clear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -523,11 +519,10 @@ done: /*------------------------------------------------------------------------- * Function: H5I__clear_type_cb * - * Purpose: Attempts to free the specified ID , calling the free + * Purpose: Attempts to free the specified ID, calling the free * function for the object. * - * Return: Success: Non-negative - * Failure: negative + * Return: TRUE/FALSE/FAIL * * Programmer: Neil Fortner * Friday, July 10, 2015 @@ -547,8 +542,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) HDassert(udata); HDassert(udata->type_ptr); - /* - * Do nothing to the object if the reference count is larger than + /* Do nothing to the object if the reference count is larger than * one and forcing is off. */ if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { @@ -589,15 +583,15 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) /*------------------------------------------------------------------------- - * Function: H5Idestroy_type + * Function: H5Idestroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. Public - * interface to H5I__destroy_type. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. Public + * interface to H5I__destroy_type. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -623,14 +617,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__destroy_type + * Function: H5I__destroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -678,8 +672,8 @@ done: * * Purpose: Public interface to H5I_register. * - * Return: Success: New object id. - * Failure: Negative + * Return: Success: New object ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -712,7 +706,7 @@ done: * for the type the ID is in and incorporating the type into * the ID which is returned to the user. * - * Return: Success: New object id + * Return: Success: New object ID * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- @@ -777,8 +771,8 @@ done: herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -788,7 +782,7 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t /* Make sure ID is not already in use */ if(NULL != (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use?!") + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") /* Make sure type number is valid */ if(type <= H5I_BADID || type >= H5I_next_type) @@ -825,13 +819,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_subst + * Function: H5I_subst * - * Purpose: Substitute a new object pointer for the specified ID. + * Purpose: Substitute a new object pointer for the specified ID. * - * Return: Success: Non-null previous object pointer associated - * with the specified ID. - * Failure: NULL + * Return: Success: Non-NULL previous object pointer associated + * with the specified ID. + * Failure: NULL * * Programmer: Quincey Koziol * Saturday, February 27, 2010 @@ -867,7 +861,7 @@ done: * * Purpose: Find an object pointer for the specified ID. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID * * Failure: NULL @@ -899,7 +893,7 @@ H5I_object(hid_t id) * its in a particular type. Public interface to * H5I_object_verify. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID. * Failure: NULL * @@ -932,7 +926,7 @@ done: * Purpose: Find an object pointer for the specified ID, verifying that * its in a particular type. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID. * Failure: NULL * @@ -962,15 +956,17 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) /*------------------------------------------------------------------------- - * Function: H5I_get_type + * Function: H5I_get_type * - * Purpose: Given an object ID return the type to which it - * belongs. The ID need not be the ID of an object which - * currently exists because the type number is encoded - * in the object ID. + * Purpose: Given an object ID return the type to which it + * belongs. The ID need not be the ID of an object which + * currently exists because the type number is encoded + * in the object ID. * - * Return: Success: A valid type number - * Failure: H5I_BADID, a negative value. + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * * Programmer: Robb Matzke * Friday, February 19, 1999 @@ -994,17 +990,17 @@ H5I_get_type(hid_t id) /*------------------------------------------------------------------------- - * Function: H5Iget_type - * - * Purpose: The public version of H5I_get_type(), obtains a type number - * when given an ID. The ID need not be the ID of an - * object which currently exists because the type number is - * encoded as part of the ID. + * Function: H5Iget_type * - * Return: Success: Type number - * Failure: H5I_BADID, a negative value + * Purpose: The public version of H5I_get_type(), obtains a type number + * when given an ID. The ID need not be the ID of an + * object which currently exists because the type number is + * encoded as part of the ID. * - * Programmer: Unknown + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * *------------------------------------------------------------------------- */ @@ -1027,16 +1023,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iremove_verify + * Function: H5Iremove_verify * - * Purpose: Removes the specified ID from its type, first checking that the - * type of the ID and the type type are the same. Public interface to - * H5I__remove_verify. + * Purpose: Removes the specified ID from its type, first checking that the + * type of the ID and the type type are the same. Public interface to + * H5I__remove_verify. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nathaniel Furrer @@ -1063,15 +1059,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__remove_verify + * Function: H5I__remove_verify * - * Purpose: Removes the specified ID from its type, first checking that - * the ID's type is the same as the ID type supplied as an argument + * Purpose: Removes the specified ID from its type, first checking that + * the ID's type is the same as the ID type supplied as an argument * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nat Furrer @@ -1096,14 +1092,14 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) /*------------------------------------------------------------------------- - * Function: H5I__remove_common + * Function: H5I__remove_common * - * Purpose: Common code to remove a specified ID from its type. + * Purpose: Common code to remove a specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Quincey Koziol * October 3, 2013 @@ -1138,14 +1134,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_remove + * Function: H5I_remove * - * Purpose: Removes the specified ID from its type. + * Purpose: Removes the specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Unknown * @@ -1178,14 +1174,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Idec_ref + * Function: H5Idec_ref * - * Purpose: Decrements the number of references outstanding for an ID. + * Purpose: Decrements the number of references outstanding for an ID. * If the reference count for an ID reaches zero, the object * will be closed. * - * Return: Success: New reference count - * Failure: Negative + * Return: Success: New reference count + * Failure: -1 * * Programmer: Quincey Koziol * Dec 7, 2003 @@ -1197,16 +1193,16 @@ H5Idec_ref(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual decrement operation */ if((ret_value = H5I_dec_app_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1214,19 +1210,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_ref + * Function: H5I_dec_ref * - * Purpose: Decrements the number of references outstanding for an ID. - * This will fail if the type is not a reference counted type. - * The ID type's 'free' function will be called for the ID - * if the reference count for the ID reaches 0 and a free - * function has been defined at type creation time. + * Purpose: Decrements the number of references outstanding for an ID. + * This will fail if the type is not a reference counted type. + * The ID type's 'free' function will be called for the ID + * if the reference count for the ID reaches 0 and a free + * function has been defined at type creation time. * - * Return: Success: New reference count. - * - * Failure: Negative + * Return: Success: New reference count * - * Programmer: Unknown + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1236,17 +1230,16 @@ H5I_dec_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - /* - * If this is the last reference to the object then invoke the type's + /* If this is the last reference to the object then invoke the type's * free method on the object. If the free method is undefined or * successful then remove the object from the type; otherwise leave * the object in the type without decrementing the reference @@ -1270,11 +1263,11 @@ H5I_dec_ref(hid_t id) if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { /* Remove the node from the type */ if(NULL == H5I__remove_common(type_ptr, id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") ret_value = 0; } /* end if */ else - ret_value = FAIL; + ret_value = -1; } /* end if */ else { --(id_ptr->count); @@ -1287,13 +1280,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref + * Function: H5I_dec_app_ref * - * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. - * count for an ID as well as normal reference count. + * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * * Programmer: Quincey Koziol * Sept 16, 2010 @@ -1306,20 +1299,20 @@ H5I_dec_app_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* Call regular decrement reference count routine */ if((ret_value = H5I_dec_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") /* Check if the ID still exists */ if(ret_value > 0) { /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust app_ref */ --(id_ptr->app_count); @@ -1340,8 +1333,8 @@ done: * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, * even when the free routine fails * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1350,7 +1343,7 @@ H5I_dec_app_ref_always_close(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); @@ -1368,7 +1361,7 @@ H5I_dec_app_ref_always_close(hid_t id) */ H5I_remove(id); - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") } done: @@ -1382,7 +1375,7 @@ done: * Purpose: Increments the number of references outstanding for an ID. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1391,16 +1384,16 @@ H5Iinc_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual increment operation */ if ((ret_value = H5I_inc_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1412,8 +1405,8 @@ done: * * Purpose: Increment the reference count for an object. * - * Return: Success: The new reference count. - * Failure: Negative + * Return: Success: The new reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1423,14 +1416,14 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust reference counts */ ++(id_ptr->count); @@ -1451,7 +1444,7 @@ done: * Purpose: Retrieves the number of references outstanding for an ID. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1460,16 +1453,16 @@ H5Iget_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual retrieve operation */ if ((ret_value = H5I_get_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1481,8 +1474,8 @@ done: * * Purpose: Retrieve the reference count for an object. * - * Return: Success: The reference count. - * Failure: Negative + * Return: Success: The reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1492,14 +1485,14 @@ H5I_get_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Set return value */ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); @@ -1515,7 +1508,7 @@ done: * Purpose: Increments the number of references outstanding for an ID type. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1524,19 +1517,19 @@ H5Iinc_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ if ((ret_value = H5I__inc_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1549,7 +1542,7 @@ done: * Purpose: Increment the reference count for an ID type. * * Return: Success: The new reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1567,7 +1560,7 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; if (!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Set return value */ ret_value = (int)(++(type_ptr->init_count)); @@ -1597,20 +1590,20 @@ done: * release (DER). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") ret_value = H5I_dec_type_ref(type); @@ -1634,24 +1627,24 @@ done: * be set to H5I_UNINIT). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ -herr_t +int H5I_dec_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") type_ptr = H5I_id_type_list_g[type]; if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Decrement the number of users of the atomic type. If this is the * last user of the type then release all atoms from the type and @@ -1678,7 +1671,7 @@ done: * Purpose: Retrieves the number of references outstanding for a type. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1687,19 +1680,19 @@ H5Iget_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ if ((ret_value = H5I__get_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1711,9 +1704,9 @@ done: * * Purpose: Retrieve the reference count for an ID type. * - * Return: Success: The reference count. + * Return: Success: The reference count * - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1747,9 +1740,7 @@ done: * Purpose: Check if the given id is valid. An id is valid if it is in * use and has an application reference count of at least 1. * - * Return: Success: TRUE if the id is valid, FALSE otherwise. - * - * Failure: Negative (never fails currently) + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -1780,24 +1771,29 @@ done: * Calls "user" callback search function, and then sets return * value, based on the result of that callback. * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * Failure: NULL + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) * *------------------------------------------------------------------------- */ static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - int ret_value = -1; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR - ret_value = (*udata->app_cb)(obj, id, udata->app_key); - if (ret_value > 0) - udata->ret_obj = obj; + cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); + + /* Set the return value based on the callback's return value */ + if(cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ + } + else if(cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ @@ -1875,17 +1871,21 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_ENTER_STATIC_NOERR - /* Don't make callback if app_ref is set and the appl. ref count is 0 */ + /* Only invoke the callback function if this ID is visible externally and + * its reference count is positive. + */ if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; + herr_t cb_ret_val; + + /* Invoke callback function */ + cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ - /* (Casting away const OK) */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); + /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ @@ -1997,11 +1997,11 @@ done: * Failure: -1 * * Comments: Public function - * If `name' is non-NULL then write up to `size' bytes into that + * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. - * Otherwise `size' is ignored and the function does not store the name, + * Otherwise 'size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. - * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) + * If an error occurs then the buffer pointed to by 'name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * If a zero is returned for the name's length, then there is no name * associated with the ID. @@ -2080,13 +2080,22 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { + H5I_type_t type; /* ID type */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", obj_id); - if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + /* Get object type */ + type = H5I_TYPE(obj_id); + + /* Call internal function */ + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") done: FUNC_LEAVE_API(ret_value) @@ -2100,30 +2109,27 @@ done: * ID given an object ID. * * Return: Success: The file ID associated with the object - * * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5I_get_file_id(hid_t obj_id, hbool_t app_ref) +H5I_get_file_id(hid_t obj_id, H5I_type_t type) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - /* Get object type */ - type = H5I_TYPE(obj_id); + /* Process based on object type */ if (type == H5I_FILE) { /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, app_ref) < 0) + if(H5I_inc_ref(obj_id, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") /* Set return value */ ret_value = obj_id; } - else if (type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + else { H5G_loc_t loc; /* Location of object */ /* Get the object location information */ @@ -2131,11 +2137,9 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0) + if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") } - else - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2148,16 +2152,16 @@ done: * * Purpose: Dump the contents of an ID to stderr for debugging. * - * Return: SUCCEED/FAIL + * Return: H5_ITER_CONT (always) * *------------------------------------------------------------------------- */ -static herr_t +static int H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t *path = NULL; /* Path to file object */ FUNC_ENTER_STATIC_NOERR @@ -2168,17 +2172,20 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Get the group location, so we get get the name */ switch (type) { case H5I_GROUP: + { path = H5G_nameof((H5G_t*)item->obj_ptr); break; - + } case H5I_DATASET: + { path = H5D_nameof((H5D_t*)item->obj_ptr); break; - + } case H5I_DATATYPE: + { path = H5T_nameof((H5T_t*)item->obj_ptr); break; - + } case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -2203,7 +2210,7 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); } - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* end H5I__debug_cb() */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 25cea4f..3bfde93 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -72,7 +72,7 @@ H5_DLL void *H5I_subst(hid_t id, const void *new_object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); -H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref); +H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t id_type); H5_DLL void *H5I_remove(hid_t id); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); @@ -80,7 +80,7 @@ H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); +H5_DLL int H5I_dec_type_ref(H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 761ba44..acf6b56 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -751,8 +751,8 @@ H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, } /* end switch */ /* Retrieve file ID for name search */ - if ((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve file ID") + if ((file_id = H5F_get_id(f, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get file ID") /* Get name, length, etc. */ if ((ret_value = H5G_get_name_by_addr(file_id, &oloc, name, size)) < 0) @@ -36,8 +36,8 @@ static char filename[6][1024]; /* Global property lists - just copies of the defaults (necessary to use * internal functions */ -hid_t fcpl_id = -1; -hid_t fapl_id = -1; +hid_t fcpl_id = H5I_INVALID_HID; +hid_t fapl_id = H5I_INVALID_HID; /*------------------------------------------------------------------------- @@ -68,8 +68,9 @@ test_single(void) TESTING("single EFC"); - /* Set EFC size to 3. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. */ + /* Set EFC size to 3. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. + */ if(H5Pset_elink_file_cache_size(fapl_id, 3) < 0) TEST_ERROR @@ -84,8 +85,9 @@ test_single(void) /* Test 1: Open file 1 through EFC, close, then open normally, verify ref - * count = 2, release EFC, verify ref count = 1. Verifies a file can be - * held open by the EFC. */ + * count = 2, release EFC, verify ref count = 1. Verifies a file can be + * held open by the EFC. + */ if(NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR @@ -502,17 +504,19 @@ test_graph_nocycle(void) TESTING("graph of EFCs without cycles"); - /* Set EFC size to 8. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. Set to a high number - * because we don't test the EFC becoming too large in this test. */ + /* Set EFC size to 8. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. Set to a high number + * because we don't test the EFC becoming too large in this test. + */ if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: Simple 3 file chain. Open file 1 through file 0, then open file - * 2 through file 1. Release file 0's EFC and verify that file 2 gets its - * ref count reduced (implying file 1 was closed). Do the same with the - * opening order reversed. */ + /* Test 1: Simple 3 file chain. Open file 1 through file 0, then open file + * 2 through file 1. Release file 0's EFC and verify that file 2 gets its + * ref count reduced (implying file 1 was closed). Do the same with the + * opening order reversed. + */ if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR @@ -847,15 +851,17 @@ test_graph_cycle(void) TESTING("graph of EFCs with cycles"); - /* Set EFC size to 8. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. Set to a high number - * because we don't test the EFC becoming too large in this test. */ + /* Set EFC size to 8. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. Set to a high number + * because we don't test the EFC becoming too large in this test. + */ if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: File caches itself. Verify that closing the file causes it to be - * actually closed, and there is no other unexpected behavior. */ + /* Test 1: File caches itself. Verify that closing the file causes it to be + * actually closed, and there is no other unexpected behavior. + */ if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR |