summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVailin Choi <vchoi@hdfgroup.org>2020-04-06 23:52:20 (GMT)
committerVailin Choi <vchoi@hdfgroup.org>2020-04-06 23:52:20 (GMT)
commitb3e966e33d8eeeecfc785fe181ad11e94dc4040b (patch)
tree075c39af9042e02e50c7777442b474f3ae19040f
parentafdcac28b85d690eebc80ab568fa5266081baaaa (diff)
parentf6514c35ea3786206a8db73e1cad8fce8fe6a715 (diff)
downloadhdf5-b3e966e33d8eeeecfc785fe181ad11e94dc4040b.zip
hdf5-b3e966e33d8eeeecfc785fe181ad11e94dc4040b.tar.gz
hdf5-b3e966e33d8eeeecfc785fe181ad11e94dc4040b.tar.bz2
Merge pull request #29 in ~VCHOI/my_third_fork from develop to bugfix/dtype_close_on_error
* commit 'f6514c35ea3786206a8db73e1cad8fce8fe6a715': (48 commits) Updated test ddl files so CMake passes after h5dump failures. Narrowed the scope of ISO_C_BINDING with ONLY additions Skip testing of passthrough VOL connector in a Family File tools test Restore previous tools library driver name behavior with passthrough VOL connector Updated tools dump output when dataset offset is undefined. Fixed unnecessary H5R casts in the tools that were raising warnings. Added checks for native optional call support in some of the tools. Changed default dataset shared struct to initialize hid_t IDs to H5I_INVALID_HID. Correct extra flags Modifications based on PR review feedback. Minor renaming in the tools code. Misc changes for h5dump VOL changes. Fix for HDFFV-11065. Fix latent bug in h5repack options file reading Add 'enable-error-stack' option to h5format_convert TRILAB-192 remove comment Minor renaming in h5dump (addr --> token) TRILAB-192 add comparable clang flags Fix some missing symbols issues in tools library A few small tweaks to the tools from review Replace usage of some standard library functions with HD- versions ...
-rw-r--r--MANIFEST41
-rwxr-xr-xbin/trace1
-rw-r--r--c++/src/CMakeLists.txt6
-rw-r--r--config/clang-warnings/developer-general3
-rw-r--r--config/clang-warnings/error-general79
-rw-r--r--config/clang-warnings/general26
-rw-r--r--config/clang-warnings/no-developer-general1
-rw-r--r--config/cmake/HDFCompilerFlags.cmake197
-rw-r--r--config/cmake/libhdf5.settings.cmake.in4
-rw-r--r--config/cmake_ext_mod/ConfigureChecks.cmake26
-rw-r--r--config/cmake_ext_mod/HDFTests.c79
-rw-r--r--config/commence.am2
-rw-r--r--config/gnu-flags144
-rw-r--r--config/gnu-warnings/4.2-4.33
-rw-r--r--config/gnu-warnings/4.2-4.42
-rw-r--r--config/gnu-warnings/4.2-4.62
-rw-r--r--config/gnu-warnings/4.2-4.last3
-rw-r--r--config/gnu-warnings/4.32
-rw-r--r--config/gnu-warnings/4.43
-rw-r--r--config/gnu-warnings/4.51
-rw-r--r--config/gnu-warnings/4.5-4.63
-rw-r--r--config/gnu-warnings/4.62
-rw-r--r--config/gnu-warnings/4.75
-rw-r--r--config/gnu-warnings/4.81
-rw-r--r--config/gnu-warnings/4.91
-rw-r--r--config/gnu-warnings/52
-rw-r--r--config/gnu-warnings/69
-rw-r--r--config/gnu-warnings/77
-rw-r--r--config/gnu-warnings/83
-rw-r--r--config/gnu-warnings/92
-rw-r--r--config/gnu-warnings/developer-4.57
-rw-r--r--config/gnu-warnings/developer-4.61
-rw-r--r--config/gnu-warnings/developer-4.77
-rw-r--r--config/gnu-warnings/developer-4.81
-rw-r--r--config/gnu-warnings/developer-71
-rw-r--r--config/gnu-warnings/developer-83
-rw-r--r--config/gnu-warnings/developer-general (renamed from config/gnu-warnings-developer-general)5
-rw-r--r--config/gnu-warnings/error-512
-rw-r--r--config/gnu-warnings/error-89
-rw-r--r--config/gnu-warnings/error-general91
-rw-r--r--config/gnu-warnings/general (renamed from config/gnu-warnings-general)2
-rw-r--r--config/gnu-warnings/no-developer-4.51
-rw-r--r--config/gnu-warnings/no-developer-4.61
-rw-r--r--config/gnu-warnings/no-developer-4.72
-rw-r--r--config/gnu-warnings/no-developer-4.81
-rw-r--r--config/gnu-warnings/no-developer-82
-rw-r--r--config/gnu-warnings/no-developer-general (renamed from config/gnu-warnings-no-developer-general)0
-rw-r--r--config/sanitizer/sanitizers.cmake109
-rw-r--r--config/toolchain/intel.cmake13
-rw-r--r--configure.ac4
-rw-r--r--fortran/src/H5Aff.F902
-rw-r--r--fortran/src/H5Dff.F9028
-rw-r--r--fortran/src/H5Eff.F902
-rw-r--r--fortran/src/H5Lff.F904
-rw-r--r--fortran/src/H5Off.F904
-rw-r--r--fortran/src/H5Pff.F902
-rw-r--r--fortran/src/H5Rff.F9018
-rw-r--r--fortran/src/H5_buildiface.F9010
-rw-r--r--fortran/src/H5f90global.F904
-rw-r--r--hl/c++/src/CMakeLists.txt6
-rw-r--r--hl/src/CMakeLists.txt6
-rw-r--r--hl/tools/h5watch/h5watch.c10
-rw-r--r--java/src/jni/CMakeLists.txt3
-rw-r--r--java/src/jni/h5aImp.c6
-rw-r--r--java/src/jni/h5eImp.c6
-rw-r--r--java/src/jni/h5lImp.c6
-rw-r--r--java/src/jni/h5oImp.c6
-rw-r--r--release_docs/RELEASE.txt24
-rw-r--r--src/CMakeLists.txt6
-rw-r--r--src/H5.c81
-rw-r--r--src/H5Dint.c5
-rw-r--r--src/H5FL.c484
-rw-r--r--src/H5FLprivate.h16
-rw-r--r--src/H5MM.c49
-rw-r--r--src/H5MMprivate.h1
-rw-r--r--src/H5TS.c116
-rw-r--r--src/H5Tconv.c2
-rw-r--r--src/H5VL.c2
-rw-r--r--src/H5public.h16
-rw-r--r--src/H5trace.c2
-rw-r--r--src/libhdf5.settings.in2
-rw-r--r--test/gen_bounds.c553
-rw-r--r--test/tmisc.c121
-rw-r--r--tools/lib/CMakeLists.txt6
-rw-r--r--tools/lib/h5diff.c4
-rw-r--r--tools/lib/h5tools.c661
-rw-r--r--tools/lib/h5tools.h50
-rw-r--r--tools/lib/h5tools_dump.c118
-rw-r--r--tools/lib/h5tools_error.h52
-rw-r--r--tools/lib/h5tools_str.c14
-rw-r--r--tools/lib/h5tools_utils.c167
-rw-r--r--tools/lib/h5tools_utils.h7
-rw-r--r--tools/libtest/h5tools_test_utils.c18
-rw-r--r--tools/src/h5copy/CMakeLists.txt2
-rw-r--r--tools/src/h5copy/h5copy.c4
-rw-r--r--tools/src/h5diff/CMakeLists.txt2
-rw-r--r--tools/src/h5dump/CMakeLists.txt2
-rw-r--r--tools/src/h5dump/h5dump.c198
-rw-r--r--tools/src/h5dump/h5dump_ddl.c40
-rw-r--r--tools/src/h5dump/h5dump_xml.c36
-rw-r--r--tools/src/h5format_convert/CMakeLists.txt2
-rw-r--r--tools/src/h5format_convert/h5format_convert.c97
-rw-r--r--tools/src/h5ls/CMakeLists.txt2
-rw-r--r--tools/src/h5ls/h5ls.c337
-rw-r--r--tools/src/h5repack/CMakeLists.txt2
-rw-r--r--tools/src/h5repack/h5repack.c9
-rw-r--r--tools/src/h5repack/h5repack.h4
-rw-r--r--tools/src/h5repack/h5repack_copy.c82
-rw-r--r--tools/src/h5repack/h5repack_main.c210
-rw-r--r--tools/src/h5repack/h5repack_verify.c22
-rw-r--r--tools/src/h5stat/CMakeLists.txt2
-rw-r--r--tools/src/h5stat/h5stat.c194
-rw-r--r--tools/src/misc/CMakeLists.txt8
-rw-r--r--tools/src/misc/h5clear.c4
-rw-r--r--tools/src/misc/h5mkgrp.c2
-rw-r--r--tools/test/h5format_convert/h5fc_chk_idx.c2
-rw-r--r--tools/test/h5format_convert/testh5fc.sh.in2
-rw-r--r--tools/test/h5repack/h5repack.sh.in2
-rw-r--r--tools/test/h5repack/h5repacktst.c10
-rw-r--r--tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl2
-rw-r--r--tools/test/h5repack/testfiles/h5repack-help.txt12
-rw-r--r--tools/test/misc/clear_open_chk.c2
-rw-r--r--tools/testfiles/tgrpnullspace.ddl2
-rw-r--r--tools/testfiles/tintsnodata.ddl18
124 files changed, 3362 insertions, 1583 deletions
diff --git a/MANIFEST b/MANIFEST
index 33fab2f..7078128 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -143,9 +143,44 @@
./config/solaris
#warnings files for both autotools and CMake
-./config/gnu-warnings-general
-./config/gnu-warnings-developer-general
-./config/gnu-warnings-no-developer-general
+./config/clang-warnings/developer-general
+./config/clang-warnings/error-general
+./config/clang-warnings/general
+./config/clang-warnings/no-developer-general
+./config/gnu-warnings/4.2-4.3
+./config/gnu-warnings/4.2-4.4
+./config/gnu-warnings/4.2-4.6
+./config/gnu-warnings/4.2-4.last
+./config/gnu-warnings/4.3
+./config/gnu-warnings/4.4
+./config/gnu-warnings/4.5
+./config/gnu-warnings/4.5-4.6
+./config/gnu-warnings/4.6
+./config/gnu-warnings/4.7
+./config/gnu-warnings/4.8
+./config/gnu-warnings/4.9
+./config/gnu-warnings/5
+./config/gnu-warnings/6
+./config/gnu-warnings/7
+./config/gnu-warnings/8
+./config/gnu-warnings/9
+./config/gnu-warnings/developer-4.5
+./config/gnu-warnings/developer-4.6
+./config/gnu-warnings/developer-4.7
+./config/gnu-warnings/developer-4.8
+./config/gnu-warnings/developer-7
+./config/gnu-warnings/developer-8
+./config/gnu-warnings/developer-general
+./config/gnu-warnings/error-5
+./config/gnu-warnings/error-8
+./config/gnu-warnings/error-general
+./config/gnu-warnings/general
+./config/gnu-warnings/no-developer-4.5
+./config/gnu-warnings/no-developer-4.6
+./config/gnu-warnings/no-developer-4.7
+./config/gnu-warnings/no-developer-4.8
+./config/gnu-warnings/no-developer-8
+./config/gnu-warnings/no-developer-general
./config/intel-warnings-general
./config/site-specific/BlankForm
diff --git a/bin/trace b/bin/trace
index de6a83f..15baa8a 100755
--- a/bin/trace
+++ b/bin/trace
@@ -132,6 +132,7 @@ $Source = "";
"H5VL_blob_optional_t" => "VA",
"void" => "x",
"FILE" => "x",
+ "H5_alloc_stats_t" => "x",
"H5A_operator_t" => "x",
"H5A_operator1_t" => "x",
"H5A_operator2_t" => "x",
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 39f0f3a..fa15c9e 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -90,6 +90,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_CPP_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
+ )
target_compile_definitions(${HDF5_CPP_LIB_TARGET}
PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings
)
@@ -107,6 +110,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_CPP_LIBSH_TARGET}
+ PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
+ )
target_compile_definitions(${HDF5_CPP_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
PRIVATE $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPICH_SKIP_MPICXX;MPICH_IGNORE_CXX_SEEK># Parallel/MPI, prevent spurious cpp/cxx warnings
diff --git a/config/clang-warnings/developer-general b/config/clang-warnings/developer-general
new file mode 100644
index 0000000..aa8c32e
--- /dev/null
+++ b/config/clang-warnings/developer-general
@@ -0,0 +1,3 @@
+-Wformat-nonliteral
+-Wmissing-noreturn
+-Wswitch-enum
diff --git a/config/clang-warnings/error-general b/config/clang-warnings/error-general
new file mode 100644
index 0000000..a9aa516
--- /dev/null
+++ b/config/clang-warnings/error-general
@@ -0,0 +1,79 @@
+#
+# HDF5 code should not trigger the following warnings under any
+# circumstances, so ask the compiler to treat them as errors:
+#
+-Werror=bad-function-cast
+-Werror=implicit-function-declaration
+-Werror=incompatible-pointer-types
+-Werror=missing-declarations
+-Werror=packed
+-Werror=shadow
+-Werror=sometimes-uninitialized
+-Werror=switch
+#
+#-Werror=discarded-qualifiers
+#
+#
+# NOTE: File Driver files are not compatible with these warnings as errors
+# H5FDdirect.c,H5FDmpio.c,H5FDros3.c,
+# -Werror=unused-function
+#
+-Wunused-function
+#
+# H5FDdrvr_module.h
+# -Werror=unused-variable
+#
+-Wunused-variable
+#
+# H5VLpassthru.c
+# -Werror=unused-parameter
+#
+-Wunused-parameter
+#
+#
+#
+# NOTE: Tools files are not compatible with these warnings as errors
+# lib/h5tools.c
+# -Werror=cast-align
+#
+-Wcast-align
+#
+# lib/h5tools_utils.c
+# -Werror=unused-parameter
+#
+#
+# NOTE: JNI files are not compatible with these warnings as errors
+# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c
+# jni/h5sImp.c,jni/h5tImp.c
+# -Werror=cast-align
+# jni/h5util.c
+# -Werror=format(-overflow)
+#
+-Wformat
+#
+#
+#Examples and tests do not use the same set of extensive warning flags as libraries
+# Here is a list of tests and examples that have issues with the stricter warnings as error
+#
+# NOTE: Test files are not compatible with these warnings as errors
+# thread_id.c,
+# -Werror=unused-function
+# dsets.c
+# -Werror=unused-parameter
+#
+#
+# NOTE: Examples files are not compatible with these warnings as errors
+# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c
+# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c
+# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c
+# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c
+# h5_reference_deprec.c
+# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
+# -Werror=strict-prototypes
+# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
+# -Werror=old-style-definition
+# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,
+# -Werror=unused-variable
+# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c
+# -Werror=unused-parameter
+
diff --git a/config/clang-warnings/general b/config/clang-warnings/general
new file mode 100644
index 0000000..f0c9b93
--- /dev/null
+++ b/config/clang-warnings/general
@@ -0,0 +1,26 @@
+# general clang warnings flags
+-Wall
+-Warray-bounds
+-Wcast-qual
+-Wconversion
+-Wdouble-promotion
+-Wextra
+-Wformat=2
+-Wframe-larger-than=16384
+-Wimplicit-fallthrough
+#
+# NOTE: Due to the divergence in the C and C++, we're dropping support for
+# compiling the C library with a C++ compiler and dropping the -Wc++-compat
+# warning.
+#
+-Wno-c++-compat
+#
+# NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add
+# it to the developer flags.
+#
+-Wno-format-nonliteral
+-Wnull-dereference
+-Wunused-const-variable
+-Wwrite-strings
+-Wpedantic
+-Wvolatile-register-var
diff --git a/config/clang-warnings/no-developer-general b/config/clang-warnings/no-developer-general
new file mode 100644
index 0000000..2f4e0c5
--- /dev/null
+++ b/config/clang-warnings/no-developer-general
@@ -0,0 +1 @@
+-Wmissing-noreturn
diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake
index 17b0854..03c6936 100644
--- a/config/cmake/HDFCompilerFlags.cmake
+++ b/config/cmake/HDFCompilerFlags.cmake
@@ -23,7 +23,7 @@ macro (ADD_H5_FLAGS h5_flag_var infile)
string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}")
#message (STATUS "str_flag=${str_flag}")
if (str_flag)
- set (${h5_flag_var} "${${h5_flag_var}} ${str_flag}")
+ list (APPEND ${h5_flag_var} "${str_flag}")
endif ()
endforeach ()
endif ()
@@ -98,12 +98,16 @@ if (HDF5_DISABLE_COMPILER_WARNINGS)
endif ()
#-----------------------------------------------------------------------------
+# HDF5 library compile options
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
# CDash is configured to only allow 3000 warnings, so
# break into groups (from the config/gnu-flags file)
#-----------------------------------------------------------------------------
-if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
+if (NOT MSVC)
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -erroff=%none -DBSD_COMP")
+ list (APPEND HDF5_CMAKE_C_FLAGS "-erroff=%none -DBSD_COMP")
else ()
# General flags
#
@@ -115,32 +119,30 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
# NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
# warnings that are emitted. If you need it, add it at configure time.
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
- ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/intel-warnings-general")
- message (STATUS "CMAKE_C_FLAGS_GENERAL=${CMAKE_C_FLAGS_GENERAL}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_GENERAL}")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wreturn-type -Wstrict-prototypes -Wuninitialized")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunknown-pragmas -Wunused-function -Wunused-variable")
+ ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings-general")
+ message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}")
+ list (APPEND H5_CFLAGS0 "-Wcomment -Wdeprecated -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith")
+ list (APPEND H5_CFLAGS0 "-Wreturn-type -Wstrict-prototypes -Wuninitialized")
+ list (APPEND H5_CFLAGS0 "-Wunknown-pragmas -Wunused-function -Wunused-variable")
# this is just a failsafe
- set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
+ list (APPEND H5_CFLAGS0 "-finline-functions")
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 18.0)
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wsign-compare -Wtrigraphs -Wwrite-strings")
+ list (APPEND H5_CFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow")
+ list (APPEND H5_CFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings")
endif()
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- ADD_H5_FLAGS (CMAKE_C_FLAGS_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-general")
- message (STATUS "CMAKE_C_FLAGS_GENERAL=${CMAKE_C_FLAGS_GENERAL}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_GENERAL}")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wbad-function-cast -Wcast-align")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wdeclaration-after-statement -Wdisabled-optimization")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-declarations")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunused-macros -Wunsafe-loop-optimizations")
+ ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/general")
+ message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-general")
# gcc automatically inlines based on the optimization level
# this is just a failsafe
- set (H5_CFLAGS0 "${H5_CFLAGS0} -finline-functions")
- message (STATUS "H5_CFLAGS0=${H5_CFLAGS0}")
+ list (APPEND H5_CFLAGS0 "-finline-functions")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ ADD_H5_FLAGS (HDF5_CMAKE_C_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general")
+ message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/error-general")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI")
+ list (APPEND HDF5_CMAKE_C_FLAGS "-Minform=inform")
endif ()
endif ()
@@ -152,100 +154,127 @@ if (NOT MSVC AND CMAKE_COMPILER_IS_GNUCC)
if (HDF5_ENABLE_DEV_WARNINGS)
message (STATUS "....HDF5 developer group warnings are enabled")
if (CMAKE_C_COMPILER_ID STREQUAL "Intel")
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Winline -Wreorder -Wport -Wstrict-aliasing")
+ list (APPEND H5_CFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing")
elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- ADD_H5_FLAGS (CMAKE_C_FLAGS_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-developer-general")
- set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_DEV_GENERAL}")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general")
endif ()
else ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
- ADD_H5_FLAGS (CMAKE_C_FLAGS_NO_DEV_GENERAL "${HDF5_SOURCE_DIR}/config/gnu-warnings-no-developer-general")
- set (H5_CFLAGS0 "${H5_CFLAGS0} ${CMAKE_C_FLAGS_NO_DEV_GENERAL}")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general")
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ ADD_H5_FLAGS (H5_CFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general")
endif ()
endif ()
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
# Append warning flags that only gcc 4.3+ knows about
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3")
#
# Technically, variable-length arrays are part of the C99 standard, but
- # we should approach them a bit cautiously... -QAK
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wlogical-op -Wlarger-than=2560 -Wvla")
+ # we should approach them a bit cautiously... Only needed for gcc 4.X
+ if (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.last")
+ endif ()
# Append more extra warning flags that only gcc 4.4+ know about
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat")
+ if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4")
+ endif ()
endif ()
# Append more extra warning flags that only gcc 4.5+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5)
- set (H5_CFLAGS1 "${H5_CFLAGS1} -Wstrict-overflow=5 -Wjump-misses-init")
- if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wunsuffixed-float-constants")
- else ()
- set (H5_CFLAGS0 "${H5_CFLAGS0} -Wno-unsuffixed-float-constants")
- endif ()
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5")
+ else ()
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5")
+ endif ()
+ endif ()
+
+ # Append more extra warning flags that only gcc 4.6 and less know about
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.2-4.6")
+ endif ()
+
+ # Append more extra warning flags that only gcc 4.5-4.6 know about
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.5 AND CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5-4.6")
endif ()
# Append more extra warning flags that only gcc 4.6+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdouble-promotion -Wtrampolines")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.6")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=const")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.6")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=const")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.6")
endif ()
endif ()
# Append more extra warning flags that only gcc 4.7+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wstack-usage=8192 -Wvector-operation-performance")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.7")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.7")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.7")
endif ()
endif ()
# Append more extra warning flags that only gcc 4.8+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.8)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.8")
if (HDF5_ENABLE_DEV_WARNINGS)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wsuggest-attribute=format")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.8")
else ()
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wno-suggest-attribute=format")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.8")
endif ()
endif ()
# Append more extra warning flags that only gcc 4.9+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.9)
- set (H5_CFLAGS2 "${H5_CFLAGS2} -Wdate-time")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.9")
endif ()
# Append more extra warning flags that only gcc 5.1+ know about
- if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.1)
- set (H5_CFLAGS3 "${H5_CFLAGS3} -Warray-bounds=2 -Wc99-c11-compat")
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0)
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/5")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/error-5")
endif ()
# Append more extra warning flags that only gcc 6.x+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 6.0)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wnull-dereference -Wunused-const-variable -Wduplicated-cond -Whsa -Wnormalized")
+ ADD_H5_FLAGS (H5_CFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/6")
endif ()
# Append more extra warning flags that only gcc 7.x+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 7.0)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict")
+ ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/7")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-7")
+ #else ()
+ # ADD_H5_FLAGS (H5_CFLAGS2 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-7")
+ endif ()
endif ()
# Append more extra warning flags that only gcc 8.x+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 8.0)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2 -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc")
+ ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/8")
+ if (HDF5_ENABLE_DEV_WARNINGS)
+ ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-8")
+ else ()
+ ADD_H5_FLAGS (H5_CFLAGS3 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-8")
+ endif ()
endif ()
# Append more extra warning flags that only gcc 9.x+ know about
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 9.0)
- set (H5_CFLAGS4 "${H5_CFLAGS4} -Wattribute-alias=2 -Wmissing-profile")
+ ADD_H5_FLAGS (H5_CFLAGS4 "${HDF5_SOURCE_DIR}/config/gnu-warnings/9")
endif ()
-elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Minform=inform")
endif ()
#-----------------------------------------------------------------------------
@@ -257,22 +286,22 @@ if (HDF5_ENABLE_ALL_WARNINGS)
if (MSVC)
if (HDF5_ENABLE_DEV_WARNINGS)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Wall /wd4668")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall /wd4668")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668")
endif ()
else ()
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/W3")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3")
endif ()
endif ()
else ()
if (CMAKE_COMPILER_IS_GNUCC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0} ${H5_CFLAGS1} ${H5_CFLAGS2} ${H5_CFLAGS3} ${H5_CFLAGS4})
endif ()
endif ()
endif ()
@@ -284,15 +313,15 @@ option (HDF5_ENABLE_GROUPZERO_WARNINGS "Enable group zero warnings" OFF)
if (HDF5_ENABLE_GROUPZERO_WARNINGS)
message (STATUS "....Group Zero warnings are enabled")
if (MSVC)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W1")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/W1")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W1")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/W1")
endif ()
else ()
if (CMAKE_COMPILER_IS_GNUCC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS0}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS0})
endif ()
endif ()
endif ()
@@ -304,14 +333,14 @@ option (HDF5_ENABLE_GROUPONE_WARNINGS "Enable group one warnings" OFF)
if (HDF5_ENABLE_GROUPONE_WARNINGS)
message (STATUS "....Group One warnings are enabled")
if (MSVC)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W2")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/W2")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W2")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2")
endif ()
else ()
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1})
endif ()
endif ()
@@ -322,14 +351,14 @@ option (HDF5_ENABLE_GROUPTWO_WARNINGS "Enable group two warnings" OFF)
if (HDF5_ENABLE_GROUPTWO_WARNINGS)
message (STATUS "....Group Two warnings are enabled")
if (MSVC)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/W3")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3")
endif ()
else ()
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2})
endif ()
endif ()
@@ -340,14 +369,14 @@ option (HDF5_ENABLE_GROUPTHREE_WARNINGS "Enable group three warnings" OFF)
if (HDF5_ENABLE_GROUPTHREE_WARNINGS)
message (STATUS "....Group Three warnings are enabled")
if (MSVC)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "/W4")
if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED)
- string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4")
endif ()
else ()
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3})
endif ()
endif ()
@@ -358,7 +387,7 @@ option (HDF5_ENABLE_GROUPFOUR_WARNINGS "Enable group four warnings" OFF)
if (HDF5_ENABLE_GROUPFOUR_WARNINGS)
message (STATUS "....Group Four warnings are enabled")
if (NOT MSVC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS4}")
+ list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4})
endif ()
endif ()
@@ -430,9 +459,9 @@ MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS)
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_PROFILING "Enable profiling flags independently from the build mode." OFF)
if (HDF5_ENABLE_PROFILING)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PROFILE_CFLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}")
if(CMAKE_CXX_COMPILER_LOADED)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROFILE_CXXFLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "${PROFILE_CXXFLAGS}")
endif ()
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING)
@@ -443,9 +472,9 @@ MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING)
#-----------------------------------------------------------------------------
option (HDF5_ENABLE_OPTIMIZATION "Enable optimization flags/settings independently from the build mode" OFF)
if (HDF5_ENABLE_OPTIMIZATION)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPTIMIZE_CFLAGS}")
+ list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}")
if(CMAKE_CXX_COMPILER_LOADED)
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZE_CXXFLAGS}")
+ list (APPEND HDF5_CMAKE_CXX_FLAGS "${OPTIMIZE_CXXFLAGS}")
endif ()
endif ()
MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION)
diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in
index 8397d68..292eaca 100644
--- a/config/cmake/libhdf5.settings.cmake.in
+++ b/config/cmake/libhdf5.settings.cmake.in
@@ -38,7 +38,7 @@ Languages:
H5_CPPFLAGS: @H5_CPPFLAGS@
AM_CPPFLAGS: @AM_CPPFLAGS@
CFLAGS: @CMAKE_C_FLAGS@
- H5_CFLAGS: @H5_CFLAGS@
+ H5_CFLAGS: @HDF5_CMAKE_C_FLAGS@
AM_CFLAGS: @AM_CFLAGS@
Shared C Library: @H5_ENABLE_SHARED_LIB@
Static C Library: @H5_ENABLE_STATIC_LIB@
@@ -54,7 +54,7 @@ Languages:
C++: @HDF5_BUILD_CPP_LIB@
@BUILD_CXX_CONDITIONAL_TRUE@ C++ Compiler: @CMAKE_CXX_COMPILER@ @CMAKE_CXX_COMPILER_VERSION@
@BUILD_CXX_CONDITIONAL_TRUE@ C++ Flags: @CMAKE_CXX_FLAGS@
-@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @H5_CXXFLAGS@
+@BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @HDF5_CMAKE_CXX_FLAGS@
@BUILD_CXX_CONDITIONAL_TRUE@ AM C++ Flags: @AM_CXXFLAGS@
@BUILD_CXX_CONDITIONAL_TRUE@ Shared C++ Library: @H5_ENABLE_SHARED_LIB@
@BUILD_CXX_CONDITIONAL_TRUE@ Static C++ Library: @H5_ENABLE_STATIC_LIB@
diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake
index 52cb7dd..93b977e 100644
--- a/config/cmake_ext_mod/ConfigureChecks.cmake
+++ b/config/cmake_ext_mod/ConfigureChecks.cmake
@@ -20,6 +20,7 @@ include (CheckSymbolExists)
include (CheckTypeSize)
include (CheckVariableExists)
include (TestBigEndian)
+include (CheckStructHasMember)
#-----------------------------------------------------------------------------
# APPLE/Darwin setup
@@ -273,11 +274,11 @@ if (MINGW OR NOT WINDOWS)
# systems.
# POSIX feature information can be found in the gcc manual at:
# http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html
- set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200112L)
+ set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=200809L)
# Need to add this so that O_DIRECT is visible for the direct
# VFD on Linux systems.
- set (HDF_EXTRA_C_FLAGS -D_GNU_SOURCE)
+ set (HDF_EXTRA_C_FLAGS ${HDF_EXTRA_C_FLAGS} -D_GNU_SOURCE)
option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON)
if (HDF_ENABLE_LARGE_FILE AND NOT DEFINED TEST_LFS_WORKS_RUN)
@@ -328,7 +329,7 @@ if (MINGW OR NOT WINDOWS)
CHECK_FUNCTION_EXISTS (fseeko ${HDF_PREFIX}_HAVE_FSEEKO)
- HDF_FUNCTION_TEST (HAVE_STAT64_STRUCT)
+ CHECK_STRUCT_HAS_MEMBER("struct stat64" st_blocks "sys/types.h;sys/stat.h" HAVE_STAT64_STRUCT)
if (HAVE_STAT64_STRUCT)
CHECK_FUNCTION_EXISTS (stat64 ${HDF_PREFIX}_HAVE_STAT64)
endif ()
@@ -438,14 +439,18 @@ if (MINGW OR NOT WINDOWS)
#-----------------------------------------------------------------------------
# Check a bunch of time functions
#-----------------------------------------------------------------------------
+ CHECK_STRUCT_HAS_MEMBER("struct tm" tm_gmtoff "time.h" ${HDF_PREFIX}_HAVE_TM_GMTOFF)
+ CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff "time.h" ${HDF_PREFIX}_HAVE___TM_GMTOFF)
+ CHECK_STRUCT_HAS_MEMBER("struct tm" tm_sec "sys/types.h;sys/time.h;time.h" ${HDF_PREFIX}_TIME_WITH_SYS_TIME)
+ if (${HDF_PREFIX}_HAVE_SYS_TIME_H)
+ CHECK_STRUCT_HAS_MEMBER("struct tm" tz_minuteswest "sys/types.h;sys/time.h;time.h" ${HDF_PREFIX}_HAVE_STRUCT_TIMEZONE)
+ else ()
+ CHECK_STRUCT_HAS_MEMBER("struct tm" tz_minuteswest "sys/types.h;time.h" ${HDF_PREFIX}_HAVE_STRUCT_TIMEZONE)
+ endif ()
CHECK_FUNCTION_EXISTS (gettimeofday ${HDF_PREFIX}_HAVE_GETTIMEOFDAY)
foreach (time_test
- HAVE_TM_GMTOFF
- HAVE___TM_GMTOFF
# HAVE_TIMEZONE
- HAVE_STRUCT_TIMEZONE
GETTIMEOFDAY_GIVES_TZ
- TIME_WITH_SYS_TIME
HAVE_TM_ZONE
HAVE_STRUCT_TM_TM_ZONE
)
@@ -453,20 +458,19 @@ if (MINGW OR NOT WINDOWS)
endforeach ()
if (NOT CYGWIN AND NOT MINGW)
HDF_FUNCTION_TEST (HAVE_TIMEZONE)
-# HDF_FUNCTION_TEST (HAVE_STAT_ST_BLOCKS)
endif ()
# ----------------------------------------------------------------------
# Does the struct stat have the st_blocks field? This field is not Posix.
#
- HDF_FUNCTION_TEST (HAVE_STAT_ST_BLOCKS)
+ CHECK_STRUCT_HAS_MEMBER("struct stat" st_blocks "sys/types.h;sys/stat.h" ${HDF_PREFIX}_HAVE_STAT_ST_BLOCKS)
# ----------------------------------------------------------------------
# How do we figure out the width of a tty in characters?
#
CHECK_FUNCTION_EXISTS (ioctl ${HDF_PREFIX}_HAVE_IOCTL)
- HDF_FUNCTION_TEST (HAVE_STRUCT_VIDEOCONFIG)
- HDF_FUNCTION_TEST (HAVE_STRUCT_TEXT_INFO)
+ CHECK_STRUCT_HAS_MEMBER ("struct videoconfig" numtextcols "" ${HDF_PREFIX}_HAVE_STRUCT_VIDEOCONFIG)
+ CHECK_STRUCT_HAS_MEMBER ("struct text_info" screenwidth "" ${HDF_PREFIX}_HAVE_STRUCT_TEXT_INFO)
CHECK_FUNCTION_EXISTS (_getvideoconfig ${HDF_PREFIX}_HAVE__GETVIDEOCONFIG)
CHECK_FUNCTION_EXISTS (gettextinfo ${HDF_PREFIX}_HAVE_GETTEXTINFO)
CHECK_FUNCTION_EXISTS (_scrsize ${HDF_PREFIX}_HAVE__SCRSIZE)
diff --git a/config/cmake_ext_mod/HDFTests.c b/config/cmake_ext_mod/HDFTests.c
index 0b9b530..31a568a 100644
--- a/config/cmake_ext_mod/HDFTests.c
+++ b/config/cmake_ext_mod/HDFTests.c
@@ -88,25 +88,6 @@ int main(void)
}
#endif
-
-#ifdef TIME_WITH_SYS_TIME
-/* Time with sys/time test */
-
-#include <sys/types.h>
-#include <sys/time.h>
-#include <time.h>
-
-int
-main ()
-{
-if ((struct tm *) 0)
-return 0;
- ;
- return 0;
-}
-
-#endif
-
#ifdef STDC_HEADERS
#include <stdlib.h>
#include <stdarg.h>
@@ -162,26 +143,6 @@ main ()
#endif /* HAVE_FUNCTION */
-#ifdef HAVE_TM_GMTOFF
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <time.h>
-SIMPLE_TEST(struct tm tm; tm.tm_gmtoff=0);
-
-#endif /* HAVE_TM_GMTOFF */
-
-#ifdef HAVE___TM_GMTOFF
-
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <time.h>
-SIMPLE_TEST(struct tm tm; tm.__tm_gmtoff=0);
-
-#endif /* HAVE_TM___GMTOFF */
-
#ifdef HAVE_TIMEZONE
#ifdef HAVE_SYS_TIME_H
@@ -192,24 +153,6 @@ SIMPLE_TEST(timezone=0);
#endif /* HAVE_TIMEZONE */
-#ifdef HAVE_STRUCT_TIMEZONE
-
-#include <sys/types.h>
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#endif
-#include <time.h>
-SIMPLE_TEST(struct timezone tz; tz.tz_minuteswest=0);
-
-#endif /* HAVE_STRUCT_TIMEZONE */
-
-#ifdef HAVE_STAT_ST_BLOCKS
-
-#include <sys/stat.h>
-SIMPLE_TEST(struct stat sb; sb.st_blocks=0);
-
-#endif /* HAVE_STAT_ST_BLOCKS */
-
#ifdef PRINTF_LL_WIDTH
#ifdef HAVE_LONG_LONG
@@ -319,16 +262,6 @@ int main()
}
#endif
-#ifdef HAVE_STAT64_STRUCT
-#include <sys/types.h>
-#include <sys/stat.h>],
-struct stat64 sb;
-int main()
-{
- return 0;
-}
-#endif
-
#ifdef TEST_DIRECT_VFD_WORKS
#include <sys/types.h>
#include <sys/stat.h>
@@ -432,18 +365,6 @@ int main ()
#endif /* HAVE_IOEO */
-#ifdef HAVE_STRUCT_VIDEOCONFIG
-
-SIMPLE_TEST(struct videoconfig w; w.numtextcols=0);
-
-#endif /* HAVE_STRUCT_VIDEOCONFIG */
-
-#ifdef HAVE_STRUCT_TEXT_INFO
-
-SIMPLE_TEST(struct text_info w; w.screenwidth=0);
-
-#endif /* HAVE_STRUCT_TEXT_INFO */
-
#if defined( HAVE_INLINE ) || defined( HAVE___INLINE__ ) || defined( HAVE___INLINE )
#ifndef __cplusplus
#if defined( HAVE_INLINE )
diff --git a/config/commence.am b/config/commence.am
index a16eee5..830c494 100644
--- a/config/commence.am
+++ b/config/commence.am
@@ -70,7 +70,7 @@ H5CPP=${DESTDIR}$(bindir)/h5c++
# instead of CFLAGS, as CFLAGS is reserved solely for the user to define.
# This applies to FCFLAGS, CXXFLAGS, CPPFLAGS, and LDFLAGS as well.
-AM_CFLAGS=@AM_CFLAGS@ @H5_CFLAGS@
+AM_CFLAGS=@AM_CFLAGS@ @H5_CFLAGS@ @H5_ECFLAGS@
AM_FCFLAGS=@AM_FCFLAGS@ @H5_FCFLAGS@
AM_CXXFLAGS=@AM_CXXFLAGS@ @H5_CXXFLAGS@
AM_CPPFLAGS=@AM_CPPFLAGS@ @H5_CPPFLAGS@
diff --git a/config/gnu-flags b/config/gnu-flags
index 11aaa71..ca0e1b4 100644
--- a/config/gnu-flags
+++ b/config/gnu-flags
@@ -18,6 +18,24 @@
#
#
+# For now, do not promote any warnings to errors.
+#
+PROMOTE_ERRORS_DFLT=no
+
+#
+# This filter rewrites -Werror= as -W, in that way demoting warnings
+# promoted to errors back to warnings, if PROMOTE_ERRORS is no.
+#
+demote_errors()
+{
+ if [ ${PROMOTE_ERRORS:-${PROMOTE_ERRORS_DFLT}} = no ]; then
+ sed 's,-Werror=,-W,g'
+ else
+ cat
+ fi
+}
+
+#
# Prepend `$srcdir/config/gnu-` to the filename suffix(es) given as
# subroutine argument(s), remove comments starting with # and ending
# at EOL, replace spans of whitespace (including newlines) with spaces,
@@ -26,7 +44,7 @@
load_gcc_arguments()
{
set -- $(for arg; do
- sed 's,#.*$,,' $srcdir/config/gnu-${arg}
+ sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors
done)
IFS=' ' echo "$*"
}
@@ -171,142 +189,120 @@ if test "X-gcc" = "X-$cc_vendor"; then
# General #
###########
- # Note that some of the flags listed here really should be developer
- # flags (listed in a separate variable, below) but we put them here
- # because they are not raised by the current code and we'd like to
- # know if they do start showing up.
- #
- # NOTE: Don't add -Wpadded here since we can't/won't fix the (many)
- # warnings that are emitted. If you need it, add it from the
- # environment variable at configure time.
- #
- # NOTE: Disable the -Wformat-nonliteral from -Wformat=2 here and re-add
- # it to the developer flags.
- #
- # NOTE: Due to the divergence in the C and C++, we're dropping support for
- # compiling the C library with a C++ compiler and dropping the -Wc++-compat
- # warning.
- H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments warnings-general)"
- H5_CFLAGS="$H5_CFLAGS -Wbad-function-cast -Wcast-align"
- H5_CFLAGS="$H5_CFLAGS -Wdeclaration-after-statement -Wdisabled-optimization"
- H5_CFLAGS="$H5_CFLAGS -Wmissing-declarations"
- H5_CFLAGS="$H5_CFLAGS -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpacked"
- H5_CFLAGS="$H5_CFLAGS -Wredundant-decls -Wstrict-prototypes -Wswitch-enum -Wswitch-default"
- H5_CFLAGS="$H5_CFLAGS -Wunused-macros -Wunsafe-loop-optimizations"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments general)"
+ H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-general)"
######################
# Developer warnings #
######################
- # (suggestions from gcc, not code problems)
- # NOTE: -Wformat-nonliteral added back in here (from being disabled in H5_CFLAGS)
- NO_DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-no-developer-general)
- DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments warnings-developer-general)
+ NO_DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments no-developer-general)
+ DEVELOPER_WARNING_CFLAGS=$(load_gcc_arguments developer-general)
#######################
# gcc 4 special cases #
#######################
- # Disable warnings about using the 'long long' type w/ gcc 4.6 and earlier
+ # GCC 4.2 through 4.6
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then
- H5_CFLAGS="$H5_CFLAGS -Wno-long-long"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.6)"
fi
- # -Wvolatile-register-var was later incorporated into -Wall and
- # only needs to be specified explicitly for gcc 4.2-4.3
+ # GCC 4.2 through 4.3
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 3; then
- H5_CFLAGS="$H5_CFLAGS -Wvolatile-register-var"
- fi
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.3)"
+ fi
- # -Wstrict-aliasing was later incorporated into -Wall and
- # only needs to be specified explicitly for gcc 4.5-4.6
+ # GCC 4.5 through 4.6
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -le 6; then
- H5_CFLAGS="$H5_CFLAGS -Wstrict-aliasing"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.5-4.6)"
fi
- # The non-valued form of -Wstrict-overflow is used in gcc 4.2-4.4
+ # GCC 4.2 through 4.4
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2 -a $cc_vers_major -eq 4 -a $cc_vers_minor -le 4; then
- H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.4)"
fi
- # -Wvla was later incorporated into -Wpedantic and
- # only needs to be specified explicitly for gcc 4
+ # GCC 4.2 through the end of GCC 4 series
if test $cc_vers_major -eq 4 -a $cc_vers_minor -ge 2; then
- H5_CFLAGS="$H5_CFLAGS -Wvla"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.2-4.last)"
fi
#############################
# Version-specific warnings #
#############################
- # gcc 4.3
+ # gcc >= 4.3
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then
- H5_CFLAGS="$H5_CFLAGS -Wlogical-op -Wlarger-than=2560"
- fi
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.3)"
+ fi
- # gcc 4.4
+ # gcc >= 4.4
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then
- H5_CFLAGS="$H5_CFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.4)"
fi
- # gcc 4.5
+ # gcc >= 4.5
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then
- H5_CFLAGS="$H5_CFLAGS -Wstrict-overflow=5 -Wjump-misses-init"
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wunsuffixed-float-constants"
- NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-unsuffixed-float-constants"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.5)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.5)"
+ NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.5)"
fi
- # gcc 4.6
+ # gcc >= 4.6
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then
- H5_CFLAGS="$H5_CFLAGS -Wdouble-promotion -Wtrampolines"
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=const"
- NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=const"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.6)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.6)"
+ NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.6)"
fi
- # gcc 4.7
+ # gcc >= 4.7
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then
- H5_CFLAGS="$H5_CFLAGS -Wstack-usage=8192 -Wvector-operation-performance"
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn"
- NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=pure -Wno-suggest-attribute=noreturn"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.7)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.7)"
+ NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.7)"
fi
- # gcc 4.8
+ # gcc >= 4.8
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wsuggest-attribute=format"
- NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=format"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.8)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-4.8)"
+ NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-4.8)"
fi
- # gcc 4.9
+ # gcc >= 4.9
if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then
- H5_CFLAGS="$H5_CFLAGS -Wdate-time"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 4.9)"
fi
- # gcc 5
+ # gcc >= 5
if test $cc_vers_major -ge 5; then
- H5_CFLAGS="$H5_CFLAGS -Warray-bounds=2 -Wc99-c11-compat"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 5)"
+ H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-5)"
fi
- # gcc 6
+ # gcc >= 6
if test $cc_vers_major -ge 6; then
- H5_CFLAGS="$H5_CFLAGS -Wnull-dereference -Wunused-const-variable -Wduplicated-cond -Whsa -Wnormalized"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 6)"
fi
- # gcc 7
+ # gcc >= 7
if test $cc_vers_major -ge 7; then
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstringop-overflow=2"
- H5_CFLAGS="$H5_CFLAGS -Walloc-zero -Walloca -Wduplicated-branches -Wformat-overflow=2 -Wformat-truncation=1 -Wimplicit-fallthrough=5 -Wrestrict"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 7)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-7)"
fi
# gcc 8
if test $cc_vers_major -ge 8; then
- DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS -Wstringop-overflow=4 -Wsuggest-attribute=cold -Wsuggest-attribute=malloc"
- NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS -Wno-suggest-attribute=cold -Wno-suggest-attribute=malloc"
- H5_CFLAGS="$H5_CFLAGS -Wattribute-alias -Wcast-align=strict -Wshift-overflow=2"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 8)"
+ H5_ECFLAGS="$H5_ECFLAGS $(load_gcc_arguments error-8)"
+ DEVELOPER_WARNING_CFLAGS="$DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments developer-8)"
+ NO_DEVELOPER_WARNING_CFLAGS="$NO_DEVELOPER_WARNING_CFLAGS $(load_gcc_arguments no-developer-8)"
fi
# gcc 9
if test $cc_vers_major -ge 9; then
- H5_CFLAGS="$H5_CFLAGS -Wattribute-alias=2 -Wmissing-profile"
+ H5_CFLAGS="$H5_CFLAGS $(load_gcc_arguments 9)"
fi
#################
diff --git a/config/gnu-warnings/4.2-4.3 b/config/gnu-warnings/4.2-4.3
new file mode 100644
index 0000000..1881797
--- /dev/null
+++ b/config/gnu-warnings/4.2-4.3
@@ -0,0 +1,3 @@
+# -Wvolatile-register-var was later incorporated into -Wall and
+# only needs to be specified explicitly for gcc 4.2-4.3
+-Wvolatile-register-var
diff --git a/config/gnu-warnings/4.2-4.4 b/config/gnu-warnings/4.2-4.4
new file mode 100644
index 0000000..ec4876f
--- /dev/null
+++ b/config/gnu-warnings/4.2-4.4
@@ -0,0 +1,2 @@
+# The non-valued form of -Wstrict-overflow is used in gcc 4.2-4.4
+-Wstrict-overflow
diff --git a/config/gnu-warnings/4.2-4.6 b/config/gnu-warnings/4.2-4.6
new file mode 100644
index 0000000..37df4ab
--- /dev/null
+++ b/config/gnu-warnings/4.2-4.6
@@ -0,0 +1,2 @@
+# Disable warnings about using the 'long long' type w/ gcc 4.6 and earlier
+-Wno-long-long
diff --git a/config/gnu-warnings/4.2-4.last b/config/gnu-warnings/4.2-4.last
new file mode 100644
index 0000000..2db90fb
--- /dev/null
+++ b/config/gnu-warnings/4.2-4.last
@@ -0,0 +1,3 @@
+# -Wvla was later incorporated into -Wpedantic and
+# only needs to be specified explicitly for gcc 4
+-Wvla
diff --git a/config/gnu-warnings/4.3 b/config/gnu-warnings/4.3
new file mode 100644
index 0000000..13d8558
--- /dev/null
+++ b/config/gnu-warnings/4.3
@@ -0,0 +1,2 @@
+-Wlarger-than=2560
+-Wlogical-op
diff --git a/config/gnu-warnings/4.4 b/config/gnu-warnings/4.4
new file mode 100644
index 0000000..42929b5
--- /dev/null
+++ b/config/gnu-warnings/4.4
@@ -0,0 +1,3 @@
+-Wframe-larger-than=16384
+-Wpacked-bitfield-compat
+-Wsync-nand
diff --git a/config/gnu-warnings/4.5 b/config/gnu-warnings/4.5
new file mode 100644
index 0000000..ddb96df
--- /dev/null
+++ b/config/gnu-warnings/4.5
@@ -0,0 +1 @@
+-Wstrict-overflow=5
diff --git a/config/gnu-warnings/4.5-4.6 b/config/gnu-warnings/4.5-4.6
new file mode 100644
index 0000000..d3035fe
--- /dev/null
+++ b/config/gnu-warnings/4.5-4.6
@@ -0,0 +1,3 @@
+# -Wstrict-aliasing was later incorporated into -Wall and
+# only needs to be specified explicitly for gcc 4.5-4.6
+-Wstrict-aliasing
diff --git a/config/gnu-warnings/4.6 b/config/gnu-warnings/4.6
new file mode 100644
index 0000000..140a20c
--- /dev/null
+++ b/config/gnu-warnings/4.6
@@ -0,0 +1,2 @@
+-Wdouble-promotion
+-Wtrampolines
diff --git a/config/gnu-warnings/4.7 b/config/gnu-warnings/4.7
new file mode 100644
index 0000000..c47fe4b
--- /dev/null
+++ b/config/gnu-warnings/4.7
@@ -0,0 +1,5 @@
+#
+# -Wstack-usage=8192 warnings need to be swept up on a branch so
+# that we can stop burdening the whole development team.
+#
+-Wstack-usage=8192
diff --git a/config/gnu-warnings/4.8 b/config/gnu-warnings/4.8
new file mode 100644
index 0000000..5dc577f
--- /dev/null
+++ b/config/gnu-warnings/4.8
@@ -0,0 +1 @@
+-Wmaybe-uninitialized
diff --git a/config/gnu-warnings/4.9 b/config/gnu-warnings/4.9
new file mode 100644
index 0000000..78aa929
--- /dev/null
+++ b/config/gnu-warnings/4.9
@@ -0,0 +1 @@
+-Wdate-time
diff --git a/config/gnu-warnings/5 b/config/gnu-warnings/5
new file mode 100644
index 0000000..32cb196
--- /dev/null
+++ b/config/gnu-warnings/5
@@ -0,0 +1,2 @@
+-Warray-bounds=2
+-Wc99-c11-compat
diff --git a/config/gnu-warnings/6 b/config/gnu-warnings/6
new file mode 100644
index 0000000..736a446
--- /dev/null
+++ b/config/gnu-warnings/6
@@ -0,0 +1,9 @@
+#
+# Careful! -Wduplicated-cond, combined with HDF5's heavy use of
+# macros, can make a lot of noise.
+#
+-Wduplicated-cond
+-Whsa
+-Wnormalized
+-Wnull-dereference
+-Wunused-const-variable
diff --git a/config/gnu-warnings/7 b/config/gnu-warnings/7
new file mode 100644
index 0000000..266f5c1
--- /dev/null
+++ b/config/gnu-warnings/7
@@ -0,0 +1,7 @@
+-Walloca
+-Walloc-zero
+-Wduplicated-branches
+-Wformat-overflow=2
+-Wformat-truncation=1
+-Wimplicit-fallthrough=5
+-Wrestrict
diff --git a/config/gnu-warnings/8 b/config/gnu-warnings/8
new file mode 100644
index 0000000..5e7519d
--- /dev/null
+++ b/config/gnu-warnings/8
@@ -0,0 +1,3 @@
+-Wattribute-alias
+-Wcast-align=strict
+-Wshift-overflow=2
diff --git a/config/gnu-warnings/9 b/config/gnu-warnings/9
new file mode 100644
index 0000000..c084350
--- /dev/null
+++ b/config/gnu-warnings/9
@@ -0,0 +1,2 @@
+-Wattribute-alias=2
+-Wmissing-profile
diff --git a/config/gnu-warnings/developer-4.5 b/config/gnu-warnings/developer-4.5
new file mode 100644
index 0000000..48df846
--- /dev/null
+++ b/config/gnu-warnings/developer-4.5
@@ -0,0 +1,7 @@
+#
+# -Wjump-misses-init makes lots of noise for a questionable benefit.
+# Can jumping over an initialization in C cause any harm, if
+# the variable is never *used* before it has been initialized?
+#
+-Wjump-misses-init
+-Wunsuffixed-float-constants
diff --git a/config/gnu-warnings/developer-4.6 b/config/gnu-warnings/developer-4.6
new file mode 100644
index 0000000..2372fbf
--- /dev/null
+++ b/config/gnu-warnings/developer-4.6
@@ -0,0 +1 @@
+-Wsuggest-attribute=const
diff --git a/config/gnu-warnings/developer-4.7 b/config/gnu-warnings/developer-4.7
new file mode 100644
index 0000000..a3b0781
--- /dev/null
+++ b/config/gnu-warnings/developer-4.7
@@ -0,0 +1,7 @@
+-Wsuggest-attribute=noreturn
+-Wsuggest-attribute=pure
+#
+# It's not clear that -Wvector-operation-performance warnings are
+# actionable, so they are demoted to "developer" warnings.
+#
+-Wvector-operation-performance
diff --git a/config/gnu-warnings/developer-4.8 b/config/gnu-warnings/developer-4.8
new file mode 100644
index 0000000..b0109e2
--- /dev/null
+++ b/config/gnu-warnings/developer-4.8
@@ -0,0 +1 @@
+-Wsuggest-attribute=format
diff --git a/config/gnu-warnings/developer-7 b/config/gnu-warnings/developer-7
new file mode 100644
index 0000000..2a3ce7e
--- /dev/null
+++ b/config/gnu-warnings/developer-7
@@ -0,0 +1 @@
+-Wstringop-overflow=2
diff --git a/config/gnu-warnings/developer-8 b/config/gnu-warnings/developer-8
new file mode 100644
index 0000000..a2ba7ca
--- /dev/null
+++ b/config/gnu-warnings/developer-8
@@ -0,0 +1,3 @@
+-Wstringop-overflow=4
+-Wsuggest-attribute=cold
+-Wsuggest-attribute=malloc
diff --git a/config/gnu-warnings-developer-general b/config/gnu-warnings/developer-general
index 698f0e0..b34c4b7 100644
--- a/config/gnu-warnings-developer-general
+++ b/config/gnu-warnings/developer-general
@@ -2,7 +2,12 @@
# NOTE: -Wformat-nonliteral added back in here (from being disabled in
# H5_CFLAGS)
-Waggregate-return
+-Wdisabled-optimization
-Wformat-nonliteral
-Winline
-Wmissing-format-attribute
-Wmissing-noreturn
+-Wswitch-default
+-Wswitch-enum
+-Wunsafe-loop-optimizations
+-Wunused-macros
diff --git a/config/gnu-warnings/error-5 b/config/gnu-warnings/error-5
new file mode 100644
index 0000000..f7e1138
--- /dev/null
+++ b/config/gnu-warnings/error-5
@@ -0,0 +1,12 @@
+-Werror=incompatible-pointer-types
+#
+# In GCC 4.4.7, the compiler gripes about shadowed global
+# declarations when a local variable uses the name of a
+# function that's in a system header file. For some reason,
+# later versions of GCC (e.g., 5.2.0) don't complain about
+# the shadowed globals. Maybe later versions are less fussy?
+# Anyway, the shadowing seems to be harmless, and GCC 4.4.7
+# is not a supported compiler, so let us promote shadowed globals
+# warnings to errors only for GCC 5 and later.
+#
+-Werror=shadow
diff --git a/config/gnu-warnings/error-8 b/config/gnu-warnings/error-8
new file mode 100644
index 0000000..36c1414
--- /dev/null
+++ b/config/gnu-warnings/error-8
@@ -0,0 +1,9 @@
+-Werror=cast-function-type
+#
+# For GCC 8, promote maybe-initialized warnings to an error. GCC 8
+# reports 0 maybe-uninitialized warnings where earlier versions
+# make many false reports. GCC 8 seems to analyze calls to static
+# in order to detect initializations that occur there. It's possible
+# that GCC 8 only performs that analysis at -O3, though.
+#
+-Werror=maybe-uninitialized
diff --git a/config/gnu-warnings/error-general b/config/gnu-warnings/error-general
new file mode 100644
index 0000000..f0e61f8
--- /dev/null
+++ b/config/gnu-warnings/error-general
@@ -0,0 +1,91 @@
+#
+# HDF5 code should not trigger the following warnings under any
+# circumstances, so ask the compiler to treat them as errors:
+#
+-Werror=bad-function-cast
+-Werror=declaration-after-statement
+-Werror=implicit-function-declaration
+-Werror=missing-declarations
+-Werror=missing-prototypes
+-Werror=nested-externs
+-Werror=old-style-definition
+-Werror=packed
+-Werror=pointer-sign
+-Werror=pointer-to-int-cast
+-Werror=redundant-decls
+-Werror=strict-prototypes
+-Werror=switch
+#
+#-Werror=discarded-qualifiers
+#
+#
+# NOTE: File Driver files are not compatible with these warnings as errors
+# H5FDdirect.c,H5FDmpio.c,H5FDros3.c,
+# -Werror=unused-function
+#
+-Wunused-function
+#
+# H5FDdrvr_module.h
+# -Werror=unused-variable
+#
+-Wunused-variable
+#
+# H5VLpassthru.c
+# -Werror=unused-parameter
+#
+-Wunused-parameter
+#
+#
+#
+# NOTE: Tools files are not compatible with these warnings as errors
+# lib/h5tools.c
+# -Werror=cast-align
+#
+-Wcast-align
+#
+# lib/h5diff_array.c
+# -Werror=unused-but-set-variable
+#
+-Wunused-but-set-variable
+#
+# lib/h5tools_utils.c
+# -Werror=unused-parameter
+#
+#
+# NOTE: JNI files are not compatible with these warnings as errors
+# jni/h5pDCPLImp.c,jni/nativeData.c,jni/h5util.c,jni/h5rImp.c
+# jni/h5sImp.c,jni/h5tImp.c
+# -Werror=cast-align
+# jni/h5util.c
+# -Werror=format(-overflow)
+#
+-Wformat
+#
+#
+#Examples and tests do not use the same set of extensive warning flags as libraries
+# Here is a list of tests and examples that have issues with the stricter warnings as error
+#
+# NOTE: Test files are not compatible with these warnings as errors
+# thread_id.c,
+# -Werror=unused-function
+# dsets.c
+# -Werror=unused-parameter
+# external.c,perform/sio_engine.c
+# -Werror=format(-truncation)
+#
+#
+# NOTE: Examples files are not compatible with these warnings as errors
+# h5_vds-eiger.c,h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,h5_vds-percival-unlim-maxmin.c
+# h5_vds-percival.c,h5_read.c,h5_rdwt.c,h5_mount.c,h5_extend.c,h5_extend_write.c
+# h5_write.c,h5_vds-simpleIO.c,h5_ref2reg_deprec.c,h5_crtgrp.c,h5_select.c
+# h5_vds-percival-unlim.c,h5_crtatt.c,h5_group.c,h5_attribute.c,h5_crtdat.c
+# h5_reference_deprec.c
+# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
+# -Werror=strict-prototypes
+# h5_rdwt.c,h5_crtgrp.c,h5_crtatt.c,h5_crtdat.c
+# -Werror=old-style-definition
+# h5_vds-exclim.c,h5_vds.c,h5_vds-exc.c,
+# -Werror=unused-variable
+# h5_elink_unix2win.c,h5_extlink.c,h5_attribute.c
+# -Werror=unused-parameter
+
diff --git a/config/gnu-warnings-general b/config/gnu-warnings/general
index 9e67b71..a7a20b7 100644
--- a/config/gnu-warnings-general
+++ b/config/gnu-warnings/general
@@ -29,4 +29,4 @@
-Wshadow
-Wundef
-Wwrite-strings
--pedantic \ No newline at end of file
+-pedantic
diff --git a/config/gnu-warnings/no-developer-4.5 b/config/gnu-warnings/no-developer-4.5
new file mode 100644
index 0000000..ef7d38f
--- /dev/null
+++ b/config/gnu-warnings/no-developer-4.5
@@ -0,0 +1 @@
+-Wno-unsuffixed-float-constants
diff --git a/config/gnu-warnings/no-developer-4.6 b/config/gnu-warnings/no-developer-4.6
new file mode 100644
index 0000000..ea9cc66
--- /dev/null
+++ b/config/gnu-warnings/no-developer-4.6
@@ -0,0 +1 @@
+-Wno-suggest-attribute=const
diff --git a/config/gnu-warnings/no-developer-4.7 b/config/gnu-warnings/no-developer-4.7
new file mode 100644
index 0000000..5b85e1f
--- /dev/null
+++ b/config/gnu-warnings/no-developer-4.7
@@ -0,0 +1,2 @@
+-Wno-suggest-attribute=noreturn
+-Wno-suggest-attribute=pure
diff --git a/config/gnu-warnings/no-developer-4.8 b/config/gnu-warnings/no-developer-4.8
new file mode 100644
index 0000000..e42e09f
--- /dev/null
+++ b/config/gnu-warnings/no-developer-4.8
@@ -0,0 +1 @@
+-Wno-suggest-attribute=format
diff --git a/config/gnu-warnings/no-developer-8 b/config/gnu-warnings/no-developer-8
new file mode 100644
index 0000000..2134bad
--- /dev/null
+++ b/config/gnu-warnings/no-developer-8
@@ -0,0 +1,2 @@
+-Wno-suggest-attribute=cold
+-Wno-suggest-attribute=malloc
diff --git a/config/gnu-warnings-no-developer-general b/config/gnu-warnings/no-developer-general
index 85dc0a3..85dc0a3 100644
--- a/config/gnu-warnings-no-developer-general
+++ b/config/gnu-warnings/no-developer-general
diff --git a/config/sanitizer/sanitizers.cmake b/config/sanitizer/sanitizers.cmake
index ecee2de..0803279 100644
--- a/config/sanitizer/sanitizers.cmake
+++ b/config/sanitizer/sanitizers.cmake
@@ -29,69 +29,66 @@ function(append value)
endfunction()
message(STATUS "USE_SANITIZER=${USE_SANITIZER}, CMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}")
-if(USE_SANITIZER AND "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
- set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
+if(USE_SANITIZER)
+ if(INTEL_CLANG OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
- append("-fno-omit-frame-pointer" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}")
+ append("-fno-omit-frame-pointer" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ message(STATUS "Building with sanitize, base flags=${CMAKE_C_SANITIZER_FLAGS}")
- if(UNIX)
-
- if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
- append("-O1" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- endif()
+ if(UNIX)
+ if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
+ append("-O1" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ endif()
- if(USE_SANITIZER MATCHES "([Aa]ddress);([Uu]ndefined)"
- OR USE_SANITIZER MATCHES "([Uu]ndefined);([Aa]ddress)")
- message(STATUS "Building with Address, Undefined sanitizers")
- append("-fsanitize=address,undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- set(MEMCHECK_TYPE AddressSanitizer)
- elseif(USE_SANITIZER MATCHES "([Aa]ddress)")
- # Optional: -fno-optimize-sibling-calls -fsanitize-address-use-after-scope
- message(STATUS "Building with Address sanitizer")
- append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- set(MEMCHECK_TYPE AddressSanitizer)
- elseif(USE_SANITIZER MATCHES "([Mm]emory([Ww]ith[Oo]rigins)?)")
- # Optional: -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2
- append("-fsanitize=memory" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- if(USE_SANITIZER MATCHES "([Mm]emory[Ww]ith[Oo]rigins)")
- message(STATUS "Building with MemoryWithOrigins sanitizer")
- append("-fsanitize-memory-track-origins" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ if(USE_SANITIZER MATCHES "([Aa]ddress);([Uu]ndefined)"
+ OR USE_SANITIZER MATCHES "([Uu]ndefined);([Aa]ddress)")
+ message(STATUS "Building with Address, Undefined sanitizers")
+ append("-fsanitize=address,undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ set(MEMCHECK_TYPE AddressSanitizer)
+ elseif(USE_SANITIZER MATCHES "([Aa]ddress)")
+ # Optional: -fno-optimize-sibling-calls -fsanitize-address-use-after-scope
+ message(STATUS "Building with Address sanitizer")
+ append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ set(MEMCHECK_TYPE AddressSanitizer)
+ elseif(USE_SANITIZER MATCHES "([Mm]emory([Ww]ith[Oo]rigins)?)")
+ # Optional: -fno-optimize-sibling-calls -fsanitize-memory-track-origins=2
+ append("-fsanitize=memory" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ if(USE_SANITIZER MATCHES "([Mm]emory[Ww]ith[Oo]rigins)")
+ message(STATUS "Building with MemoryWithOrigins sanitizer")
+ append("-fsanitize-memory-track-origins" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ else()
+ message(STATUS "Building with Memory sanitizer")
+ endif()
+ set(MEMCHECK_TYPE MemorySanitizer)
+ elseif(USE_SANITIZER MATCHES "([Uu]ndefined)")
+ message(STATUS "Building with Undefined sanitizer")
+ append("-fsanitize=undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ if(EXISTS "${BLACKLIST_FILE}")
+ append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ endif()
+ set(MEMCHECK_TYPE UndefinedBehaviorSanitizer)
+ elseif(USE_SANITIZER MATCHES "([Tt]hread)")
+ message(STATUS "Building with Thread sanitizer")
+ append("-fsanitize=thread" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ set(MEMCHECK_TYPE ThreadSanitizer)
+ elseif(USE_SANITIZER MATCHES "([Ll]eak)")
+ message(STATUS "Building with Leak sanitizer")
+ append("-fsanitize=leak" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ set(MEMCHECK_TYPE LeakSanitizer)
else()
- message(STATUS "Building with Memory sanitizer")
+ message(
+ FATAL_ERROR "Unsupported value of USE_SANITIZER: ${USE_SANITIZER}")
endif()
- set(MEMCHECK_TYPE MemorySanitizer)
- elseif(USE_SANITIZER MATCHES "([Uu]ndefined)")
- message(STATUS "Building with Undefined sanitizer")
- append("-fsanitize=undefined" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- if(EXISTS "${BLACKLIST_FILE}")
- append("-fsanitize-blacklist=${BLACKLIST_FILE}" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ elseif(MSVC)
+ if(USE_SANITIZER MATCHES "([Aa]ddress)")
+ message(STATUS "Building with Address sanitizer")
+ append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
+ else()
+ message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}")
endif()
- set(MEMCHECK_TYPE UndefinedBehaviorSanitizer)
- elseif(USE_SANITIZER MATCHES "([Tt]hread)")
- message(STATUS "Building with Thread sanitizer")
- append("-fsanitize=thread" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- set(MEMCHECK_TYPE ThreadSanitizer)
- elseif(USE_SANITIZER MATCHES "([Ll]eak)")
- message(STATUS "Building with Leak sanitizer")
- append("-fsanitize=leak" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- set(MEMCHECK_TYPE LeakSanitizer)
else()
- message(
- FATAL_ERROR "Unsupported value of USE_SANITIZER: ${USE_SANITIZER}")
+ message(FATAL_ERROR "USE_SANITIZER is not supported on this platform.")
endif()
- elseif(MSVC)
- if(USE_SANITIZER MATCHES "([Aa]ddress)")
- message(STATUS "Building with Address sanitizer")
- append("-fsanitize=address" CMAKE_C_SANITIZER_FLAGS CMAKE_CXX_SANITIZER_FLAGS)
- else()
- message(
- FATAL_ERROR
- "This sanitizer not yet supported in the MSVC environment: ${USE_SANITIZER}"
- )
- endif()
- else()
- message(FATAL_ERROR "USE_SANITIZER is not supported on this platform.")
endif()
-
endif()
diff --git a/config/toolchain/intel.cmake b/config/toolchain/intel.cmake
index 97f6a64..ae1d2f8 100644
--- a/config/toolchain/intel.cmake
+++ b/config/toolchain/intel.cmake
@@ -3,9 +3,16 @@
set(CMAKE_COMPILER_VENDOR "intel")
-set(CMAKE_C_COMPILER icc)
-set(CMAKE_CXX_COMPILER icpc)
-set(CMAKE_Fortran_COMPILER ifort)
+if(USE_SANITIZER)
+ set(CMAKE_C_COMPILER icl)
+ set(CMAKE_CXX_COMPILER icl++)
+ set(CMAKE_Fortran_COMPILER ifort)
+ set(INTEL_CLANG ON)
+else ()
+ set(CMAKE_C_COMPILER icc)
+ set(CMAKE_CXX_COMPILER icpc)
+ set(CMAKE_Fortran_COMPILER ifort)
+endif ()
# the following is used if cross-compiling
set(CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/configure.ac b/configure.ac
index 0eada60..5851b32 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,7 +103,11 @@ AC_SUBST([AR_FLAGS])
## H5_CFLAGS (and company) are for CFLAGS that should be used on HDF5, but
## not exported to h5cc (or h5fc, etc.)
+##
+## H5_ECFLAGS is for warnings that should be treated as errors.
+##
AC_SUBST([H5_CFLAGS])
+AC_SUBST([H5_ECFLAGS])
AC_SUBST([H5_CPPFLAGS])
AC_SUBST([H5_FCFLAGS])
AC_SUBST([H5_CXXFLAGS])
diff --git a/fortran/src/H5Aff.F90 b/fortran/src/H5Aff.F90
index a728f2d..abfaae9 100644
--- a/fortran/src/H5Aff.F90
+++ b/fortran/src/H5Aff.F90
@@ -72,7 +72,7 @@
MODULE H5A
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_NULL_CHAR, C_LOC, C_INT
USE H5GLOBAL
diff --git a/fortran/src/H5Dff.F90 b/fortran/src/H5Dff.F90
index 77f0a15..ec73f60 100644
--- a/fortran/src/H5Dff.F90
+++ b/fortran/src/H5Dff.F90
@@ -87,7 +87,7 @@
MODULE H5D
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR
USE H5GLOBAL
PRIVATE h5dread_vl_integer, h5dread_vl_real, h5dread_vl_string
@@ -959,7 +959,7 @@ CONTAINS
SUBROUTINE h5dwrite_vl_string(dset_id, mem_type_id, buf, dims, str_len, &
hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING, ONLY : c_char
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1191,7 +1191,7 @@ CONTAINS
SUBROUTINE h5dwrite_reference_obj(dset_id, mem_type_id, buf, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1223,7 +1223,7 @@ CONTAINS
SUBROUTINE h5dwrite_reference_dsetreg(dset_id, mem_type_id, buf, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1285,7 +1285,7 @@ CONTAINS
SUBROUTINE h5dwrite_char_scalar(dset_id, mem_type_id, buf, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1303,7 +1303,7 @@ CONTAINS
SUBROUTINE h5dwrite_char_scalar_fix(dset_id, mem_type_id, buf, buf_len, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1336,7 +1336,7 @@ CONTAINS
SUBROUTINE h5dread_reference_obj(dset_id, mem_type_id, buf, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1431,7 +1431,7 @@ CONTAINS
SUBROUTINE h5dread_char_scalar(dset_id, mem_type_id, buf, dims, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1461,7 +1461,7 @@ CONTAINS
SUBROUTINE h5dread_char_scalar_fix(dset_id, mem_type_id, buf, buf_len, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1519,7 +1519,7 @@ CONTAINS
!*****
SUBROUTINE h5dwrite_ptr(dset_id, mem_type_id, buf, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1584,7 +1584,7 @@ CONTAINS
!*****
SUBROUTINE h5dread_ptr(dset_id, mem_type_id, buf, hdferr, &
mem_space_id, file_space_id, xfer_prp)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: dset_id ! Dataset identifier
INTEGER(HID_T), INTENT(IN) :: mem_type_id ! Memory datatype identifier
@@ -1638,7 +1638,7 @@ CONTAINS
!
SUBROUTINE h5dfill_integer(fill_value, space_id, buf, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER, INTENT(IN), TARGET :: fill_value ! Fill value
INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier
@@ -1688,7 +1688,7 @@ CONTAINS
! March 12, 2003
!
SUBROUTINE h5dfill_c_float(fill_valuer, space_id, buf, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
REAL(KIND=C_FLOAT), INTENT(IN), TARGET :: fill_valuer ! Fill value
INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier
@@ -1810,7 +1810,7 @@ CONTAINS
! March 12, 2003
!
SUBROUTINE h5dfill_char(fill_value, space_id, buf, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
CHARACTER, INTENT(IN), TARGET :: fill_value ! Fill value
INTEGER(HID_T), INTENT(IN) :: space_id ! Memory dataspace selection identifier
diff --git a/fortran/src/H5Eff.F90 b/fortran/src/H5Eff.F90
index fcd08ff..435d967 100644
--- a/fortran/src/H5Eff.F90
+++ b/fortran/src/H5Eff.F90
@@ -264,7 +264,7 @@ CONTAINS
!
! Fortran2003 Interface:
SUBROUTINE h5eset_auto_f(printflag, hdferr, estack_id, func, client_data)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR
INTEGER , INTENT(IN) :: printflag
INTEGER , INTENT(OUT) :: hdferr
INTEGER(HID_T), INTENT(IN) , OPTIONAL :: estack_id
diff --git a/fortran/src/H5Lff.F90 b/fortran/src/H5Lff.F90
index f672547..66f5b5c 100644
--- a/fortran/src/H5Lff.F90
+++ b/fortran/src/H5Lff.F90
@@ -1343,7 +1343,7 @@ CONTAINS
!
! Fortran2003 Interface:
SUBROUTINE h5literate_f(group_id, index_type, order, idx, op, op_data, return_value, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: group_id
INTEGER , INTENT(IN) :: index_type
@@ -1423,7 +1423,7 @@ CONTAINS
! Fortran2003 Interface:
SUBROUTINE h5literate_by_name_f(loc_id, group_name, index_type, order, &
idx, op, op_data, return_value, hdferr, lapl_id)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_FUNPTR
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: loc_id
CHARACTER(LEN=*), INTENT(IN) :: group_name
diff --git a/fortran/src/H5Off.F90 b/fortran/src/H5Off.F90
index 2b025a7..fb17942 100644
--- a/fortran/src/H5Off.F90
+++ b/fortran/src/H5Off.F90
@@ -1017,7 +1017,7 @@ CONTAINS
! Fortran2003 Interface:
SUBROUTINE h5oget_info_f(object_id, object_info, hdferr, fields)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: object_id
TYPE(h5o_info_t), INTENT(OUT), TARGET :: object_info
@@ -1079,7 +1079,7 @@ CONTAINS
SUBROUTINE h5oget_info_by_idx_f(loc_id, group_name, index_field, order, n, &
object_info, hdferr, lapl_id, fields)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T) , INTENT(IN) :: loc_id
CHARACTER(LEN=*), INTENT(IN) :: group_name
diff --git a/fortran/src/H5Pff.F90 b/fortran/src/H5Pff.F90
index 61d30b8..883e49a 100644
--- a/fortran/src/H5Pff.F90
+++ b/fortran/src/H5Pff.F90
@@ -38,7 +38,7 @@
MODULE H5P
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR
USE H5GLOBAL
USE H5fortkit
diff --git a/fortran/src/H5Rff.F90 b/fortran/src/H5Rff.F90
index 6c2ba28..c911b1a 100644
--- a/fortran/src/H5Rff.F90
+++ b/fortran/src/H5Rff.F90
@@ -341,7 +341,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rcreate_object_f(loc_id, name, ref, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id ! Location identifier
CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the object at location specified
@@ -450,7 +450,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rcreate_ptr_f(loc_id, name, ref_type, ref, hdferr, space_id)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id ! Location identifier
CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the dataset at location specified
@@ -498,7 +498,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rdereference_object_f(obj_id, ref, ref_obj_id, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: obj_id ! Dataset identifier
TYPE(hobj_ref_t_f), INTENT(IN), TARGET :: ref ! Object reference
@@ -541,7 +541,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rdereference_region_f(obj_id, ref, ref_obj_id, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: obj_id ! Dataset identifier
TYPE(hdset_reg_ref_t_f), INTENT(IN), TARGET :: ref ! Object reference
@@ -582,7 +582,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rdereference_ptr_f(obj_id, ref_type, ref, ref_obj_id, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: obj_id ! Valid identifier for the file containing the
! referenced object or any object in that file.
@@ -622,7 +622,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rget_name_object_f(loc_id, ref, name, hdferr, size)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id
TYPE(hobj_ref_t_f), INTENT(IN), TARGET :: ref
@@ -669,7 +669,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rget_name_region_f(loc_id, ref, name, hdferr, size)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id
TYPE(hdset_reg_ref_t_f), INTENT(IN), TARGET :: ref
@@ -718,7 +718,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rget_name_ptr_f(loc_id, ref_type, ref, name, hdferr, size)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id
INTEGER, INTENT(IN) :: ref_type
@@ -767,7 +767,7 @@ CONTAINS
!
! Signature:
SUBROUTINE h5rget_obj_type_f(loc_id, ref_type, ref, obj_type, hdferr)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR
IMPLICIT NONE
INTEGER(HID_T), INTENT(IN) :: loc_id
INTEGER, INTENT(IN) :: ref_type
diff --git a/fortran/src/H5_buildiface.F90 b/fortran/src/H5_buildiface.F90
index f793b7f..be53806 100644
--- a/fortran/src/H5_buildiface.F90
+++ b/fortran/src/H5_buildiface.F90
@@ -47,7 +47,7 @@
#include <H5config_f.inc>
PROGRAM H5_buildiface
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_CHAR, C_LOC
IMPLICIT NONE
! These values are valid REAL KINDs (with corresponding C float) found during configure
@@ -135,7 +135,7 @@ PROGRAM H5_buildiface
WRITE(11,'(A)') "MODULE H5_GEN"
- WRITE(11,'(2X,A)') 'USE, INTRINSIC :: ISO_C_BINDING'
+ WRITE(11,'(2X,A)') 'USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_PTR, C_LOC'
WRITE(11,'(2X,A)') 'USE H5GLOBAL'
WRITE(11,'(2X,A)') 'USE H5A'
@@ -712,7 +712,6 @@ PROGRAM H5_buildiface
WRITE(11,'(A)') ' SUBROUTINE h5dread_rkind_'//TRIM(ADJUSTL(chr2))&
&//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
@@ -752,7 +751,6 @@ PROGRAM H5_buildiface
WRITE(11,'(A)') ' SUBROUTINE h5dread_ikind_'//TRIM(ADJUSTL(chr2))&
&//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
@@ -787,7 +785,6 @@ PROGRAM H5_buildiface
! Subroutine API
WRITE(11,'(A)') ' SUBROUTINE h5dread_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
@@ -827,7 +824,6 @@ PROGRAM H5_buildiface
WRITE(11,'(A)') ' SUBROUTINE h5dwrite_rkind_'//TRIM(ADJUSTL(chr2))&
&//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
@@ -866,7 +862,6 @@ PROGRAM H5_buildiface
WRITE(11,'(A)') ' SUBROUTINE h5dwrite_ikind_'//TRIM(ADJUSTL(chr2))&
&//'_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
@@ -900,7 +895,6 @@ PROGRAM H5_buildiface
! Subroutine API
WRITE(11,'(A)') ' SUBROUTINE h5dwrite_ckind_rank'//chr_rank(j)//'(dset_id, mem_type_id, buf, dims, hdferr, &'
WRITE(11,'(A)') ' mem_space_id, file_space_id, xfer_prp)'
- WRITE(11,'(A)') ' USE, INTRINSIC :: ISO_C_BINDING'
WRITE(11,'(A)') ' IMPLICIT NONE'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: dset_id'
WRITE(11,'(A)') ' INTEGER(HID_T), INTENT(IN) :: mem_type_id'
diff --git a/fortran/src/H5f90global.F90 b/fortran/src/H5f90global.F90
index 6b601e9..46759cf 100644
--- a/fortran/src/H5f90global.F90
+++ b/fortran/src/H5f90global.F90
@@ -819,7 +819,7 @@ CONTAINS
SUBROUTINE H5_Fortran_string_c2f(c_string, f_string)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR, C_NULL_CHAR
IMPLICIT NONE
CHARACTER(KIND=C_CHAR, LEN=*), INTENT(IN) :: c_string
CHARACTER(LEN=*), INTENT(OUT) :: f_string
@@ -845,7 +845,7 @@ CONTAINS
SUBROUTINE H5_Fortran_string_f2c(f_string, c_string)
- USE, INTRINSIC :: ISO_C_BINDING
+ USE, INTRINSIC :: ISO_C_BINDING, ONLY : C_CHAR, C_NULL_CHAR
IMPLICIT NONE
CHARACTER(LEN=*), INTENT(IN) :: f_string
CHARACTER(KIND=C_CHAR, LEN=*), INTENT(OUT) :: c_string
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 866f372..01c8126 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -14,6 +14,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_HL_CPP_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
+ )
TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_HL_CPP_LIB_TARGET} PUBLIC ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET})
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIB_TARGET}")
@@ -28,6 +31,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_HL_CPP_LIBSH_TARGET}
+ PRIVATE "${HDF5_CMAKE_CXX_FLAGS}"
+ )
target_compile_definitions(${HDF5_HL_CPP_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
)
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index 55d84c7..7975a1a 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -38,6 +38,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_HL_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
TARGET_C_PROPERTIES (${HDF5_HL_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_HL_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET})
H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} STATIC 0)
@@ -52,6 +55,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_HL_LIBSH_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
target_compile_definitions(${HDF5_HL_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
)
diff --git a/hl/tools/h5watch/h5watch.c b/hl/tools/h5watch/h5watch.c
index b7f583c..ff9a078 100644
--- a/hl/tools/h5watch/h5watch.c
+++ b/hl/tools/h5watch/h5watch.c
@@ -822,7 +822,9 @@ main(int argc, const char *argv[])
char *fname = NULL; /* File name */
char *dname = NULL; /* Dataset name */
void *edata; /* Error reporting */
+ void *tools_edata; /* Error reporting */
H5E_auto2_t func; /* Error reporting */
+ H5E_auto2_t tools_func; /* Error reporting */
char *x; /* Temporary string pointer */
hid_t fid = -1; /* File ID */
hid_t fapl = -1; /* File access property list */
@@ -838,6 +840,10 @@ main(int argc, const char *argv[])
/* Initialize h5tools lib */
h5tools_init();
+ /* Disable tools error reporting */
+ H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+
/* To exit from h5watch for SIGTERM signal */
if(HDsignal(SIGTERM, catch_signal) == SIG_ERR) {
error_msg("An error occurred while setting a signal handler.\n");
@@ -890,7 +896,7 @@ main(int argc, const char *argv[])
do {
while(fname && *fname) {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, NULL, drivername, sizeof drivername);
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl, FALSE, drivername, sizeof drivername);
if(fid >= 0) {
HDfprintf(stdout, "Opened \"%s\" with %s driver.\n", fname, drivername);
@@ -966,6 +972,8 @@ main(int argc, const char *argv[])
}
H5Eset_auto2(H5E_DEFAULT, func, edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
+
/* exit */
leave(h5tools_getstatus());
} /* main() */
diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt
index d945c33..dc9b223 100644
--- a/java/src/jni/CMakeLists.txt
+++ b/java/src/jni/CMakeLists.txt
@@ -79,6 +79,9 @@ add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JA
target_include_directories (${HDF5_JAVA_JNI_LIB_TARGET}
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
)
+target_compile_options(${HDF5_JAVA_JNI_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+)
TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED)
target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET})
set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni)
diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c
index fb933ad..8b3f9e5 100644
--- a/java/src/jni/h5aImp.c
+++ b/java/src/jni/h5aImp.c
@@ -2167,7 +2167,7 @@ H5A_iterate_cb
jobject visit_callback = wrapper->visit_callback;
jstring str;
JNIEnv *cbenv = NULL;
- jclass cls;
+ jclass cbcls;
jvalue args[4];
void *op_data = (void *)wrapper->op_data;
jint status = -1;
@@ -2177,10 +2177,10 @@ H5A_iterate_cb
H5_JNI_FATAL_ERROR(CBENVONLY, "H5A_iterate_cb: failed to attach current thread to JVM");
}
- if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+ if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I")))
+ if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5A_info_t;Lhdf/hdf5lib/callbacks/H5A_iterate_t;)I")))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/java/src/jni/h5eImp.c b/java/src/jni/h5eImp.c
index 7ea4223..80e23a1 100644
--- a/java/src/jni/h5eImp.c
+++ b/java/src/jni/h5eImp.c
@@ -523,7 +523,7 @@ H5E_walk_cb
jobject cb_info_t = NULL;
jvalue args[7];
JNIEnv *cbenv = NULL;
- jclass cls;
+ jclass cbcls;
void *op_data = (void *)wrapper->op_data;
jint status = FAIL;
@@ -532,10 +532,10 @@ H5E_walk_cb
H5_JNI_FATAL_ERROR(CBENVONLY, "H5E_walk_cb: failed to attach current thread to JVM");
}
- if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+ if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I")))
+ if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(ILhdf/hdf5lib/structs/H5E_error2_t;Lhdf/hdf5lib/callbacks/H5E_walk_t;)I")))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
args[0].j = info->cls_id;
diff --git a/java/src/jni/h5lImp.c b/java/src/jni/h5lImp.c
index e60e1ab..b5312bd 100644
--- a/java/src/jni/h5lImp.c
+++ b/java/src/jni/h5lImp.c
@@ -672,7 +672,7 @@ H5L_iterate_cb
jobject visit_callback = wrapper->visit_callback;
jstring str;
JNIEnv *cbenv = NULL;
- jclass cls;
+ jclass cbcls;
jvalue args[5];
void *op_data = (void *)wrapper->op_data;
jint status = -1;
@@ -683,10 +683,10 @@ H5L_iterate_cb
}
/* Get the Method ID for the "callback" function of the H5L_iterate_t class */
- if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+ if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I")))
+ if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5L_info_t;Lhdf/hdf5lib/callbacks/H5L_iterate_opdata_t;)I")))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/java/src/jni/h5oImp.c b/java/src/jni/h5oImp.c
index 1d828a1..33bec85 100644
--- a/java/src/jni/h5oImp.c
+++ b/java/src/jni/h5oImp.c
@@ -548,7 +548,7 @@ H5O_iterate_cb
jobject token;
jstring str;
JNIEnv *cbenv = NULL;
- jclass cls;
+ jclass cbcls;
jvalue args[12];
void *op_data = (void *)wrapper->op_data;
jint status = FAIL;
@@ -558,10 +558,10 @@ H5O_iterate_cb
H5_JNI_FATAL_ERROR(CBENVONLY, "H5O_iterate_cb: failed to attach current thread to JVM");
}
- if (NULL == (cls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
+ if (NULL == (cbcls = CBENVPTR->GetObjectClass(CBENVONLY, visit_callback)))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
- if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I")))
+ if (NULL == (mid = CBENVPTR->GetMethodID(CBENVONLY, cbcls, "callback", "(JLjava/lang/String;Lhdf/hdf5lib/structs/H5O_info_t;Lhdf/hdf5lib/callbacks/H5O_iterate_opdata_t;)I")))
CHECK_JNI_EXCEPTION(CBENVONLY, JNI_FALSE);
if (NULL == (str = CBENVPTR->NewStringUTF(CBENVONLY, name)))
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index c7a8e53..ff1d99b 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -48,6 +48,30 @@ New Features
Configuration:
-------------
+ - CMake ConfigureChecks.cmake file now uses CHECK_STRUCT_HAS_MEMBER
+
+ Some handcrafted tests in HDFTests.c has been removed and the CMake
+ CHECK_STRUCT_HAS_MEMBER module has been used.
+
+ (ADB - 2020/03/24, TRILAB-24)
+
+ - Both build systems use same set of warnings flags
+
+ GNU C warnings flags were moved to files in a config sub-folder
+ named gnu-warnings. Flags that only are available for a specific
+ version of the compiler are in files named with that version.
+ Clang C warnings flags were moved to files in a config sub-folder
+ named clang-warnings.
+
+ There are flags in named "error-xxx" files with warnings that may
+ be promoted to errors. Some source files may still need fixes.
+
+ There are also pairs of files named "developer-xxx" and "no-developer-xxx"
+ that are chosen by the CMake option:HDF5_ENABLE_DEV_WARNINGS or the
+ configure option:--enable-developer-warnings.
+
+ (ADB - 2020/03/24, TRILAB-192)
+
- Added test script for file size compare
if CMake minimum version is at least 3.14, the fileCompareTest.cmake
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f582056..3f7d73a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1137,6 +1137,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
target_compile_definitions(${HDF5_LIB_TARGET}
PUBLIC
${HDF_EXTRA_C_FLAGS}
@@ -1173,6 +1176,9 @@ if (BUILD_SHARED_LIBS)
PUBLIC "$<$<BOOL:${HDF5_ENABLE_HDFS}>:${HDFS_INCLUDE_DIR}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_LIBSH_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
target_compile_definitions(${HDF5_LIBSH_TARGET}
PUBLIC
"H5_BUILT_AS_DYNAMIC_LIB"
diff --git a/src/H5.c b/src/H5.c
index 62a1c09..59882e3 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -558,6 +558,87 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5get_free_list_sizes
+ *
+ * Purpose: Gets the current size of the different kinds of free lists that
+ * the library uses to manage memory. The free list sizes can be set with
+ * H5set_free_list_limits and garbage collected with H5garbage_collect.
+ * These lists are global for the entire library.
+ *
+ * Parameters:
+ * size_t *reg_size; OUT: The current size of all "regular" free list memory used
+ * size_t *arr_size; OUT: The current size of all "array" free list memory used
+ * size_t *blk_size; OUT: The current size of all "block" free list memory used
+ * size_t *fac_size; OUT: The current size of all "factory" free list memory used
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, March 6, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size,
+ size_t *fac_size)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE4("e", "*z*z*z*z", reg_size, arr_size, blk_size, fac_size);
+
+ /* Call the free list function to actually get the sizes */
+ if(H5FL_get_free_list_sizes(reg_size, arr_size, blk_size, fac_size) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get garbage collection sizes")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5get_free_list_sizes() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5get_alloc_stats
+ *
+ * Purpose: Gets the memory allocation statistics for the library, if the
+ * --enable-memory-alloc-sanity-check option was given when building the
+ * library. Applications can check whether this option was enabled by
+ * detecting if the 'H5_MEMORY_ALLOC_SANITY_CHECK' macro is defined. This
+ * option is enabled by default for debug builds of the library and
+ * disabled by default for non-debug builds. If the option is not enabled,
+ * all the values returned with be 0. These statistics are global for the
+ * entire library, but don't include allocations from chunked dataset I/O
+ * filters or non-native VOL connectors.
+ *
+ * Parameters:
+ * H5_alloc_stats_t *stats; OUT: Memory allocation statistics
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, March 7, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5get_alloc_stats(H5_alloc_stats_t *stats)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("e", "*x", stats);
+
+ /* Call the internal allocation stat routine to get the values */
+ if(H5MM_get_alloc_stats(stats) < 0)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get allocation stats")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5get_alloc_stats() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5_debug_mask
*
* Purpose: Set runtime debugging flags according to the string S. The
diff --git a/src/H5Dint.c b/src/H5Dint.c
index 173ae3f..954b619 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -207,6 +207,9 @@ H5D__init_package(void)
/* Reset the "default dataset" information */
HDmemset(&H5D_def_dset, 0, sizeof(H5D_shared_t));
+ H5D_def_dset.type_id = H5I_INVALID_HID;
+ H5D_def_dset.dapl_id = H5I_INVALID_HID;
+ H5D_def_dset.dcpl_id = H5I_INVALID_HID;
/* Get the default dataset creation property list values and initialize the
* default dataset with them.
@@ -2560,7 +2563,7 @@ done:
/*-------------------------------------------------------------------------
* Function: H5D__get_offset
*
- * Purpose: Private function for H5D__get_offset. Returns the address
+ * Purpose: Private function for H5Dget_offset(). Returns the address
* of dataset in file.
*
* Return: Success: The address of dataset
diff --git a/src/H5FL.c b/src/H5FL.c
index 9ed867d..66d27fb 100644
--- a/src/H5FL.c
+++ b/src/H5FL.c
@@ -130,17 +130,23 @@ static H5FL_track_t *H5FL_out_head_g = NULL;
#endif /* H5FL_TRACK */
/* Forward declarations of local static functions */
+static void * H5FL__malloc(size_t mem_size);
+static herr_t H5FL__reg_init(H5FL_reg_head_t *head);
static herr_t H5FL__reg_gc(void);
static herr_t H5FL__reg_gc_list(H5FL_reg_head_t *head);
static int H5FL__reg_term(void);
-static herr_t H5FL__arr_gc(void);
-static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head);
-static int H5FL__arr_term(void);
-static herr_t H5FL__blk_gc(void);
+static H5FL_blk_node_t *H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size);
+static H5FL_blk_node_t *H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size);
+static herr_t H5FL__blk_init(H5FL_blk_head_t *head);
static herr_t H5FL__blk_gc_list(H5FL_blk_head_t *head);
+static herr_t H5FL__blk_gc(void);
static int H5FL__blk_term(void);
-static herr_t H5FL__fac_gc(void);
+static herr_t H5FL__arr_init(H5FL_arr_head_t *head);
+static herr_t H5FL__arr_gc_list(H5FL_arr_head_t *head);
+static herr_t H5FL__arr_gc(void);
+static int H5FL__arr_term(void);
static herr_t H5FL__fac_gc_list(H5FL_fac_head_t *head);
+static herr_t H5FL__fac_gc(void);
static int H5FL__fac_term_all(void);
/* Declare a free list to manage the H5FL_blk_node_t struct */
@@ -217,7 +223,7 @@ H5FL_term_package(void)
/*-------------------------------------------------------------------------
- * Function: H5FL_malloc
+ * Function: H5FL__malloc
*
* Purpose: Attempt to allocate space using malloc. If malloc fails, garbage
* collect and try again. If malloc fails again, then return NULL.
@@ -228,16 +234,14 @@ H5FL_term_package(void)
* Programmer: Quincey Koziol
* Tuesday, August 1, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static void *
-H5FL_malloc(size_t mem_size)
+H5FL__malloc(size_t mem_size)
{
void *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Attempt to allocate the memory requested */
if(NULL==(ret_value=H5MM_malloc(mem_size))) {
@@ -252,11 +256,11 @@ H5FL_malloc(size_t mem_size)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FL_malloc() */
+} /* end H5FL__malloc() */
/*-------------------------------------------------------------------------
- * Function: H5FL_reg_init
+ * Function: H5FL__reg_init
*
* Purpose: Initialize a free list for a certain type. Right now, this just
* adds the free list to the list of things to garbage collect.
@@ -267,17 +271,15 @@ done:
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5FL_reg_init(H5FL_reg_head_t *head)
+H5FL__reg_init(H5FL_reg_head_t *head)
{
H5FL_reg_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Allocate a new garbage collection node */
if(NULL == (new_node = (H5FL_reg_gc_node_t *)H5MM_malloc(sizeof(H5FL_reg_gc_node_t))))
@@ -304,7 +306,7 @@ H5FL_reg_init(H5FL_reg_head_t *head)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FL_reg_init() */
+} /* end H5FL__reg_init() */
/*-------------------------------------------------------------------------
@@ -317,8 +319,6 @@ done:
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -403,8 +403,6 @@ done:
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -419,7 +417,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
/* Make certain the list is initialized first */
if(!head->init)
- if(H5FL_reg_init(head)<0)
+ if(H5FL__reg_init(head) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'regular' blocks")
/* Check for nodes available on the free list first */
@@ -438,7 +436,7 @@ H5FL_reg_malloc(H5FL_reg_head_t *head H5FL_TRACK_PARAMS)
} /* end if */
/* Otherwise allocate a node */
else {
- if (NULL==(ret_value = H5FL_malloc(head->size)))
+ if(NULL == (ret_value = H5FL__malloc(head->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Increment the number of blocks allocated in list */
@@ -480,8 +478,6 @@ done:
* Programmer: Quincey Koziol
* Monday, December 23, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -524,35 +520,34 @@ static herr_t
H5FL__reg_gc_list(H5FL_reg_head_t *head)
{
H5FL_reg_node_t *free_list; /* Pointer to nodes in free list being garbage collected */
- size_t total_mem; /* Total memory used on list */
FUNC_ENTER_STATIC_NOERR
- /* Calculate the total memory used on this list */
- total_mem = head->onlist * head->size;
-
/* For each free list being garbage collected, walk through the nodes and free them */
free_list = head->list;
while(free_list != NULL) {
- void *tmp; /* Temporary node pointer */
+ H5FL_reg_node_t *tmp; /* Temporary node pointer */
+ /* Get the pointer to the next node */
tmp = free_list->next;
- /* Decrement the count of nodes allocated and free the node */
- head->allocated--;
-
+ /* Free the block */
H5MM_free(free_list);
- free_list = (H5FL_reg_node_t *)tmp;
+ /* Advance to the next node */
+ free_list = tmp;
} /* end while */
+ /* Decrement the count of nodes allocated and free the node */
+ head->allocated -= head->onlist;
+
+ /* Decrement global count of free memory on "regular" lists */
+ H5FL_reg_gc_head.mem_freed -= (head->onlist * head->size);
+
/* Indicate no free nodes on the free list */
head->list = NULL;
head->onlist = 0;
- /* Decrement global count of free memory on "regular" lists */
- H5FL_reg_gc_head.mem_freed -= total_mem;
-
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL__reg_gc_list() */
@@ -568,10 +563,6 @@ H5FL__reg_gc_list(H5FL_reg_head_t *head)
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- * Broke into two parts, one for looping over all the free lists and
- * another for freeing each list - QAK 7/25/00
- *
*-------------------------------------------------------------------------
*/
static herr_t
@@ -670,7 +661,7 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f
/*-------------------------------------------------------------------------
- * Function: H5FL_blk_find_list
+ * Function: H5FL__blk_find_list
*
* Purpose: Finds the free list for blocks of a given size. Also moves that
* free list node to the head of the priority queue (if it isn't there
@@ -684,16 +675,14 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_reg_gc_head.f
* Programmer: Quincey Koziol
* Thursday, March 23, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static H5FL_blk_node_t *
-H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size)
+H5FL__blk_find_list(H5FL_blk_node_t **head, size_t size)
{
H5FL_blk_node_t *temp = NULL; /* Temp. pointer to node in the native list */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_STATIC_NOERR
/* Find the correct free list */
temp=*head;
@@ -729,11 +718,11 @@ H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size)
} /* end if */
FUNC_LEAVE_NOAPI(temp)
-} /* end H5FL_blk_find_list() */
+} /* end H5FL__blk_find_list() */
/*-------------------------------------------------------------------------
- * Function: H5FL_blk_create_list
+ * Function: H5FL__blk_create_list
*
* Purpose: Creates a new free list for blocks of the given size at the
* head of the priority queue.
@@ -745,47 +734,38 @@ H5FL_blk_find_list(H5FL_blk_node_t **head, size_t size)
* Programmer: Quincey Koziol
* Thursday, March 23, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static H5FL_blk_node_t *
-H5FL_blk_create_list(H5FL_blk_node_t **head, size_t size)
+H5FL__blk_create_list(H5FL_blk_node_t **head, size_t size)
{
- H5FL_blk_node_t *temp; /* Temp. pointer to node in the list */
H5FL_blk_node_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Allocate room for the new free list node */
- if(NULL==(temp=H5FL_MALLOC(H5FL_blk_node_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk info")
+ if(NULL == (ret_value = H5FL_CALLOC(H5FL_blk_node_t)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, NULL, "memory allocation failed for chunk info")
/* Set the correct values for the new free list */
- temp->size=size;
- temp->list=NULL;
+ ret_value->size = size;
/* Attach to head of priority queue */
- if(*head==NULL) {
- *head=temp;
- temp->next=temp->prev=NULL;
- } /* end if */
+ if(NULL == *head)
+ *head = ret_value;
else {
- temp->next=*head;
- (*head)->prev=temp;
- temp->prev=NULL;
- *head=temp;
+ ret_value->next = *head;
+ (*head)->prev = ret_value;
+ *head = ret_value;
} /* end else */
- ret_value=temp;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FL_blk_create_list() */
+} /* end H5FL__blk_create_list() */
/*-------------------------------------------------------------------------
- * Function: H5FL_blk_init
+ * Function: H5FL__blk_init
*
* Purpose: Initialize a priority queue of a certain type. Right now, this just
* adds the PQ to the list of things to garbage collect.
@@ -796,17 +776,15 @@ done:
* Programmer: Quincey Koziol
* Saturday, March 25, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5FL_blk_init(H5FL_blk_head_t *head)
+H5FL__blk_init(H5FL_blk_head_t *head)
{
H5FL_blk_gc_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Allocate a new garbage collection node */
if(NULL == (new_node = (H5FL_blk_gc_node_t *)H5MM_malloc(sizeof(H5FL_blk_gc_node_t))))
@@ -824,7 +802,7 @@ H5FL_blk_init(H5FL_blk_head_t *head)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FL_blk_init() */
+} /* end H5FL__blk_init() */
/*-------------------------------------------------------------------------
@@ -839,8 +817,6 @@ done:
* Programmer: Quincey Koziol
* Monday, December 16, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
htri_t
@@ -856,10 +832,11 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size)
/* check if there is a free list for blocks of this size */
/* and if there are any blocks available on the list */
- if((free_list = H5FL_blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL)
+ if((free_list = H5FL__blk_find_list(&(head->head), size)) != NULL && free_list->list != NULL)
ret_value = TRUE;
else
ret_value = FALSE;
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_blk_free_block_avail() */
@@ -878,8 +855,6 @@ H5FL_blk_free_block_avail(H5FL_blk_head_t *head, size_t size)
* Programmer: Quincey Koziol
* Thursday, March 23, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -897,31 +872,40 @@ H5FL_blk_malloc(H5FL_blk_head_t *head, size_t size H5FL_TRACK_PARAMS)
/* Make certain the list is initialized first */
if(!head->init)
- if(H5FL_blk_init(head)<0)
+ if(H5FL__blk_init(head) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'block' list")
/* check if there is a free list for blocks of this size */
/* and if there are any blocks available on the list */
- if((free_list=H5FL_blk_find_list(&(head->head),size))!=NULL && free_list->list!=NULL) {
+ if(NULL != (free_list = H5FL__blk_find_list(&(head->head), size)) && NULL != free_list->list) {
/* Remove the first node from the free list */
temp=free_list->list;
free_list->list=free_list->list->next;
/* Decrement the number of blocks & memory used on free list */
+ free_list->onlist--;
head->onlist--;
head->list_mem-=size;
/* Decrement the amount of global "block" free list memory in use */
H5FL_blk_gc_head.mem_freed-=size;
-
} /* end if */
/* No free list available, or there are no nodes on the list, allocate a new node to give to the user */
else {
+ /* Check if there was no free list for native blocks of this size */
+ if(NULL == free_list)
+ /* Create a new list node and insert it to the queue */
+ free_list = H5FL__blk_create_list(&(head->head), size);
+ HDassert(free_list);
+
/* Allocate new node, with room for the page info header and the actual page data */
- if(NULL == (temp = (H5FL_blk_list_t *)H5FL_malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size)))
+ if(NULL == (temp = (H5FL_blk_list_t *)H5FL__malloc(sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE + size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for chunk")
- /* Increment the number of blocks allocated */
+ /* Increment the number of blocks of this size */
+ free_list->allocated++;
+
+ /* Increment the total number of blocks allocated */
head->allocated++;
} /* end else */
@@ -970,8 +954,6 @@ done:
* Programmer: Quincey Koziol
* Monday, December 23, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1011,8 +993,6 @@ done:
* Programmer: Quincey Koziol
* Thursday, March 23, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1055,7 +1035,7 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
#endif /* H5FL_TRACK */
/* Get the pointer to the native block info header in front of the native block to free */
- temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - sizeof(H5FL_blk_list_t))); /*lint !e826 Pointer-to-pointer cast is appropriate here */
+ temp = (H5FL_blk_list_t *)((void *)((unsigned char *)block - (sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE))); /*lint !e826 Pointer-to-pointer cast is appropriate here */
/* Save the block's size for later */
free_size=temp->size;
@@ -1064,20 +1044,18 @@ H5FL_blk_free(H5FL_blk_head_t *head, void *block)
HDmemset(temp,255,free_size + sizeof(H5FL_blk_list_t) + H5FL_TRACK_SIZE);
#endif /* H5FL_DEBUG */
- /* check if there is a free list for native blocks of this size */
- if((free_list=H5FL_blk_find_list(&(head->head),free_size))==NULL) {
+ /* Check if there is a free list for native blocks of this size */
+ if(NULL == (free_list = H5FL__blk_find_list(&(head->head), free_size)))
/* No free list available, create a new list node and insert it to the queue */
- free_list=H5FL_blk_create_list(&(head->head),free_size);
- HDassert(free_list);
- } /* end if */
+ free_list = H5FL__blk_create_list(&(head->head), free_size);
+ HDassert(free_list);
/* Prepend the free'd native block to the front of the free list */
- if(free_list!=NULL) {
- temp->next=free_list->list; /* Overwrites the size field in union */
- free_list->list=temp;
- } /* end if */
+ temp->next = free_list->list; /* Note: Overwrites the size field in union */
+ free_list->list = temp;
/* Increment the number of blocks on free list */
+ free_list->onlist++;
head->onlist++;
head->list_mem += free_size;
@@ -1113,8 +1091,6 @@ done:
* Programmer: Quincey Koziol
* Thursday, March 23, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1191,44 +1167,70 @@ done:
static herr_t
H5FL__blk_gc_list(H5FL_blk_head_t *head)
{
+ H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list page node */
+
FUNC_ENTER_STATIC_NOERR
/* Loop through all the nodes in the block free list queue */
- while(head->head != NULL) {
- H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */
- void *temp; /* Temp. ptr to the free list page node */
+ blk_head = head->head;
+ while(blk_head != NULL) {
+ H5FL_blk_node_t *blk_next; /* Temp. ptr to the next free list node */
+ H5FL_blk_list_t *list; /* The free list of native nodes of a particular size */
- temp = head->head->next;
+ /* Sanity check */
+ HDassert((blk_head->onlist && blk_head->list) || (0 == blk_head->onlist && NULL == blk_head->list));
/* Loop through all the blocks in the free list, freeing them */
- list = head->head->list;
+ list = blk_head->list;
while(list != NULL) {
- void *next; /* Temp. ptr to the free list list node */
+ H5FL_blk_list_t *next; /* Temp. ptr to the free list list node */
+ /* Get the pointer to the next node */
next = list->next;
- /* Decrement the number of blocks & memory allocated from this PQ */
- head->allocated--;
- head->list_mem -= head->head->size;
-
- /* Decrement global count of free memory on "block" lists */
- H5FL_blk_gc_head.mem_freed -= head->head->size;
-
/* Free the block */
H5MM_free(list);
- list = (H5FL_blk_list_t *)next;
+ /* Advance to the next node */
+ list = next;
} /* end while */
- /* Free the free list node */
- head->head = H5FL_FREE(H5FL_blk_node_t, head->head);
+ /* Decrement the number of blocks allocated from this list */
+ blk_head->allocated -= blk_head->onlist;
+ head->allocated -= blk_head->onlist;
+
+ /* Decrement count of free memory on this "block" list */
+ head->list_mem -= (blk_head->onlist * blk_head->size);
+
+ /* Decrement global count of free memory on "block" lists */
+ H5FL_blk_gc_head.mem_freed -= (blk_head->onlist * blk_head->size);
+
+ /* Indicate no free nodes on the free list */
+ blk_head->list = NULL;
+ blk_head->onlist = 0;
- /* Advance to the next free list */
- head->head = (H5FL_blk_node_t *)temp;
+ /* Get pointer to next node */
+ blk_next = blk_head->next;
+
+ /* Check for list completely unused now */
+ if(0 == blk_head->allocated) {
+ /* Patch this node out of the PQ */
+ if(head->head == blk_head)
+ head->head = blk_head->next;
+ if(blk_head->prev)
+ blk_head->prev->next = blk_head->next;
+ if(blk_head->next)
+ blk_head->next->prev = blk_head->prev;
+
+ /* Free the free list node */
+ H5FL_FREE(H5FL_blk_node_t, blk_head);
+ } /* end if */
+
+ /* Advance to the next node */
+ blk_head = blk_next;
} /* end while */
/* Indicate no free nodes on the free list */
- head->head = NULL;
head->onlist = 0;
/* Double check that all the memory on this list is recycled */
@@ -1257,7 +1259,7 @@ H5FL__blk_gc(void)
H5FL_blk_gc_node_t *gc_node; /* Pointer into the list of things to garbage collect */
herr_t ret_value = SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Walk through all the free lists, free()'ing the nodes */
gc_node = H5FL_blk_gc_head.first;
@@ -1341,7 +1343,7 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f
/*-------------------------------------------------------------------------
- * Function: H5FL_arr_init
+ * Function: H5FL__arr_init
*
* Purpose: Initialize a free list for a arrays of certain type. Right now,
* this just adds the free list to the list of things to garbage collect.
@@ -1352,18 +1354,16 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_blk_gc_head.f
* Programmer: Quincey Koziol
* Saturday, March 25, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
static herr_t
-H5FL_arr_init(H5FL_arr_head_t *head)
+H5FL__arr_init(H5FL_arr_head_t *head)
{
H5FL_gc_arr_node_t *new_node; /* Pointer to the node for the new list to garbage collect */
size_t u; /* Local index variable */
herr_t ret_value=SUCCEED; /* return value*/
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_STATIC
/* Allocate a new garbage collection node */
if(NULL == (new_node = (H5FL_gc_arr_node_t *)H5MM_malloc(sizeof(H5FL_gc_arr_node_t))))
@@ -1389,7 +1389,7 @@ H5FL_arr_init(H5FL_arr_head_t *head)
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FL_arr_init() */
+} /* end H5FL__arr_init() */
/*-------------------------------------------------------------------------
@@ -1403,8 +1403,6 @@ done:
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1481,8 +1479,6 @@ done:
* Programmer: Quincey Koziol
* Saturday, March 25, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1500,7 +1496,7 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
/* Make certain the list is initialized first */
if(!head->init)
- if(H5FL_arr_init(head)<0)
+ if(H5FL__arr_init(head) < 0)
HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, NULL, "can't initialize 'array' blocks")
/* Sanity check that the number of elements is supported */
@@ -1527,10 +1523,13 @@ H5FL_arr_malloc(H5FL_arr_head_t *head, size_t elem)
} /* end if */
/* Otherwise allocate a node */
else {
- if(NULL == (new_obj = (H5FL_arr_list_t *)H5FL_malloc(sizeof(H5FL_arr_list_t)+mem_size)))
+ if(NULL == (new_obj = (H5FL_arr_list_t *)H5FL__malloc(sizeof(H5FL_arr_list_t)+mem_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
- /* Increment the number of blocks allocated in list */
+ /* Increment the number of blocks of this size */
+ head->list_arr[elem].allocated++;
+
+ /* Increment the number of blocks allocated in list, of all sizes */
head->allocated++;
} /* end else */
@@ -1556,8 +1555,6 @@ done:
* Programmer: Quincey Koziol
* Monday, December 23, 2002
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1594,8 +1591,6 @@ done:
* Programmer: Quincey Koziol
* Saturday, March 25, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1667,34 +1662,35 @@ H5FL__arr_gc_list(H5FL_arr_head_t *head)
for(u = 0; u < (unsigned)head->maxelem; u++) {
if(head->list_arr[u].onlist > 0) {
H5FL_arr_list_t *arr_free_list; /* Pointer to nodes in free list being garbage collected */
- size_t total_mem; /* Total memory used on list */
-
- /* Calculate the total memory used on this list */
- total_mem = head->list_arr[u].onlist * head->list_arr[u].size;
/* For each free list being garbage collected, walk through the nodes and free them */
arr_free_list = head->list_arr[u].list;
while(arr_free_list != NULL) {
- void *tmp; /* Temporary node pointer */
+ H5FL_arr_list_t *tmp; /* Temporary node pointer */
+ /* Get the pointer to the next node */
tmp = arr_free_list->next;
- /* Decrement the count of nodes allocated and free the node */
- head->allocated--;
+ /* Free the node */
H5MM_free(arr_free_list);
- arr_free_list = (H5FL_arr_list_t *)tmp;
+ /* Advance to the next node */
+ arr_free_list = tmp;
} /* end while */
- /* Indicate no free nodes on the free list */
- head->list_arr[u].list = NULL;
- head->list_arr[u].onlist = 0;
+ /* Decrement the count of nodes allocated */
+ head->list_arr[u].allocated -= head->list_arr[u].onlist;
+ head->allocated -= head->list_arr[u].onlist;
/* Decrement count of free memory on this "array" list */
- head->list_mem -= total_mem;
+ head->list_mem -= (head->list_arr[u].onlist * head->list_arr[u].size);
/* Decrement global count of free memory on "array" lists */
- H5FL_arr_gc_head.mem_freed -= total_mem;
+ H5FL_arr_gc_head.mem_freed -= (head->list_arr[u].onlist * head->list_arr[u].size);
+
+ /* Indicate no free nodes on the free list */
+ head->list_arr[u].list = NULL;
+ head->list_arr[u].onlist = 0;
} /* end if */
} /* end for */
@@ -1820,8 +1816,6 @@ HDprintf("%s: head->name = %s, head->allocated = %d\n", FUNC, H5FL_arr_gc_head.f
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1856,8 +1850,6 @@ H5FL_seq_free(H5FL_seq_head_t *head, void *obj)
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1889,8 +1881,6 @@ H5FL_seq_malloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1922,8 +1912,6 @@ H5FL_seq_calloc(H5FL_seq_head_t *head, size_t elem H5FL_TRACK_PARAMS)
* Programmer: Quincey Koziol
* Saturday, April 3, 2004
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -1955,11 +1943,6 @@ H5FL_seq_realloc(H5FL_seq_head_t *head, void * obj, size_t new_elem H5FL_TRACK_P
* Programmer: Quincey Koziol
* Wednesday, February 2, 2005
*
- * Modifications:
- * Neil Fortner
- * Friday, December 19, 2008
- * Totally rewritten to support new factory implementation
- *
*-------------------------------------------------------------------------
*/
H5FL_fac_head_t *
@@ -2032,11 +2015,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, February 2, 2005
*
- * Modifications:
- * Neil Fortner
- * Friday, December 19, 2008
- * Totally rewritten to support new factory implementation
- *
*-------------------------------------------------------------------------
*/
void *
@@ -2120,11 +2098,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, February 2, 2005
*
- * Modifications:
- * Neil Fortner
- * Friday, December 19, 2008
- * Totally rewritten to support new factory implementation
- *
*-------------------------------------------------------------------------
*/
void *
@@ -2155,7 +2128,7 @@ H5FL_fac_malloc(H5FL_fac_head_t *head H5FL_TRACK_PARAMS)
} /* end if */
/* Otherwise allocate a node */
else {
- if (NULL==(ret_value = H5FL_malloc(head->size)))
+ if(NULL == (ret_value = H5FL__malloc(head->size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* Increment the number of blocks allocated in list */
@@ -2197,11 +2170,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, February 2, 2005
*
- * Modifications:
- * Neil Fortner
- * Friday, December 19, 2008
- * Totally rewritten to support new factory implementation
- *
*-------------------------------------------------------------------------
*/
void *
@@ -2245,35 +2213,34 @@ static herr_t
H5FL__fac_gc_list(H5FL_fac_head_t *head)
{
H5FL_fac_node_t *free_list; /* Pointer to nodes in free list being garbage collected */
- size_t total_mem; /* Total memory used on list */
FUNC_ENTER_STATIC_NOERR
- /* Calculate the total memory used on this list */
- total_mem = head->onlist * head->size;
-
/* For each free list being garbage collected, walk through the nodes and free them */
free_list = head->list;
while(free_list != NULL) {
- void *tmp; /* Temporary node pointer */
+ H5FL_fac_node_t *tmp; /* Temporary node pointer */
+ /* Get the pointer to the next node */
tmp = free_list->next;
- /* Decrement the count of nodes allocated and free the node */
- head->allocated--;
-
+ /* Free the block */
H5MM_free(free_list);
- free_list = (H5FL_fac_node_t *)tmp;
+ /* Advance to the next node */
+ free_list = tmp;
} /* end while */
+ /* Decrement the count of nodes allocated and free the node */
+ head->allocated -= head->onlist;
+
+ /* Decrement global count of free memory on "factory" lists */
+ H5FL_fac_gc_head.mem_freed -= (head->onlist * head->size);
+
/* Indicate no free nodes on the free list */
head->list = NULL;
head->onlist = 0;
- /* Decrement global count of free memory on "factory" lists */
- H5FL_fac_gc_head.mem_freed -= total_mem;
-
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5FL__fac_gc_list() */
@@ -2329,11 +2296,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, February 2, 2005
*
- * Modifications:
- * Neil Fortner
- * Friday, December 19, 2008
- * Totally rewritten to support new factory implementation
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -2438,8 +2400,6 @@ HDprintf("%s: head->size = %d, head->allocated = %d\n", FUNC, (int)H5FL_fac_gc_h
* Programmer: Quincey Koziol
* Friday, March 24, 2000
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -2495,10 +2455,6 @@ done:
* Programmer: Quincey Koziol
* Wednesday, August 2, 2000
*
- * Modifications: Neil Fortner
- * Wednesday, April 8, 2009
- * Added support for factory free lists
- *
*-------------------------------------------------------------------------
*/
herr_t
@@ -2531,3 +2487,127 @@ H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_l
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5FL_set_free_list_limits() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5FL_get_free_list_sizes
+ *
+ * Purpose: Gets the current size of the different kinds of free lists.
+ * These lists are global for the entire library. The size returned
+ * included nodes that are freed and awaiting garbage collection /
+ * reallocation.
+ *
+ * Parameters:
+ * size_t *reg_size; OUT: The current size of all "regular" free list memory used
+ * size_t *arr_size; OUT: The current size of all "array" free list memory used
+ * size_t *blk_size; OUT: The current size of all "block" free list memory used
+ * size_t *fac_size; OUT: The current size of all "factory" free list memory used
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Friday, March 6, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size,
+ size_t *fac_size)
+{
+ FUNC_ENTER_NOAPI_NOERR
+
+ /* Retrieve the amount of "regular" memory used */
+ if(reg_size) {
+ H5FL_reg_gc_node_t *gc_node; /* Pointer into the list of lists */
+
+ /* Walk through all the free lists, counting the amount of memory */
+ *reg_size = 0;
+ gc_node = H5FL_reg_gc_head.first;
+ while(gc_node != NULL) {
+ H5FL_reg_head_t *reg_list = gc_node->list; /* Head of list */
+
+ /* Sanity check */
+ HDassert(reg_list->init);
+
+ /* Add the amount of memory for this list */
+ *reg_size += (reg_list->size * reg_list->allocated);
+
+ /* Go on to the next free list */
+ gc_node = gc_node->next;
+ } /* end while */
+ } /* end if */
+
+ /* Retrieve the amount of "array" memory used */
+ if(arr_size) {
+ H5FL_gc_arr_node_t *gc_arr_node; /* Pointer into the list of things to garbage collect */
+
+ /* Walk through all the free lists, counting the amount of memory */
+ *arr_size = 0;
+ gc_arr_node = H5FL_arr_gc_head.first;
+ while(gc_arr_node != NULL) {
+ H5FL_arr_head_t *head = gc_arr_node->list; /* Head of array list elements */
+
+ /* Sanity check */
+ HDassert(head->init);
+
+ /* Check for any allocated elements in this list */
+ if(head->allocated > 0) {
+ unsigned u;
+
+ /* Walk through the free lists for array sizes */
+ for(u = 0; u < (unsigned)head->maxelem; u++)
+ /* Add the amount of memory for this size */
+ *arr_size += head->list_arr[u].allocated * head->list_arr[u].size;
+ } /* end if */
+
+ /* Go on to the next free list */
+ gc_arr_node = gc_arr_node->next;
+ } /* end while */
+ } /* end if */
+
+ /* Retrieve the amount of "block" memory used */
+ if(blk_size) {
+ H5FL_blk_gc_node_t *gc_blk_node; /* Pointer into the list of things */
+
+ /* Walk through all the free lists */
+ gc_blk_node = H5FL_blk_gc_head.first;
+ *blk_size = 0;
+ while(gc_blk_node != NULL) {
+ H5FL_blk_node_t *blk_head; /* Temp. ptr to the free list block node */
+
+ /* Loop through all the nodes in the block free list queue */
+ blk_head = gc_blk_node->pq->head;
+ while(blk_head != NULL) {
+ /* Add size of blocks on this list */
+ *blk_size += (blk_head->allocated * blk_head->size);
+
+ /* Get pointer to next node */
+ blk_head = blk_head->next;
+ } /* end while */
+
+ /* Go on to the next free list */
+ gc_blk_node = gc_blk_node->next;
+ } /* end while */
+ } /* end if */
+
+ /* Retrieve the amount of "factory" memory used */
+ if(fac_size) {
+ H5FL_fac_gc_node_t *gc_fac_node; /* Pointer into the list of things to garbage collect */
+
+ /* Walk through all the free lists */
+ gc_fac_node = H5FL_fac_gc_head.first;
+ *fac_size = 0;
+ while(gc_fac_node != NULL) {
+ H5FL_fac_head_t *fac_head = gc_fac_node->list; /* Head node for factory list */
+
+ /* Add size of blocks on this list */
+ *fac_size += (fac_head->allocated * fac_head->size);
+
+ /* Go on to the next free list to garbage collect */
+ gc_fac_node = gc_fac_node->next;
+ } /* end while */
+ } /* end if */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5FL_get_free_list_sizes() */
+
diff --git a/src/H5FLprivate.h b/src/H5FLprivate.h
index d5a68d7..94a51e5 100644
--- a/src/H5FLprivate.h
+++ b/src/H5FLprivate.h
@@ -157,6 +157,8 @@ typedef union H5FL_blk_list_t {
/* Data structure for priority queue node of block free lists */
typedef struct H5FL_blk_node_t {
size_t size; /* Size of the blocks in the list */
+ unsigned allocated; /* Number of blocks of this size allocated */
+ unsigned onlist; /* Number of blocks on free list */
H5FL_blk_list_t *list; /* List of free blocks */
struct H5FL_blk_node_t *next; /* Pointer to next free list in queue */
struct H5FL_blk_node_t *prev; /* Pointer to previous free list in queue */
@@ -165,9 +167,9 @@ typedef struct H5FL_blk_node_t {
/* Data structure for priority queue of native block free lists */
typedef struct H5FL_blk_head_t {
hbool_t init; /* Whether the free list has been initialized */
- unsigned allocated; /* Number of blocks allocated */
- unsigned onlist; /* Number of blocks on free list */
- size_t list_mem; /* Amount of memory in block on free list */
+ unsigned allocated; /* Total number of blocks allocated */
+ unsigned onlist; /* Total number of blocks on free list */
+ size_t list_mem; /* Total amount of memory in blocks on free list */
const char *name; /* Name of the type */
H5FL_blk_node_t *head; /* Pointer to first free list in queue */
} H5FL_blk_head_t;
@@ -228,7 +230,9 @@ typedef union H5FL_arr_list_t {
/* Data structure for each size of array element */
typedef struct H5FL_arr_node_t {
- size_t size; /* Size of the blocks in the list */
+ size_t size; /* Size of the blocks in the list (in bytes) */
+ /* (Note: base_size + <# of elem> * elem_size) */
+ unsigned allocated; /* Number of blocks allocated of this element size */
unsigned onlist; /* Number of blocks on free list */
H5FL_arr_list_t *list; /* List of free blocks */
} H5FL_arr_node_t;
@@ -236,7 +240,7 @@ typedef struct H5FL_arr_node_t {
/* Data structure for free list of array blocks */
typedef struct H5FL_arr_head_t {
hbool_t init; /* Whether the free list has been initialized */
- unsigned allocated; /* Number of blocks allocated */
+ unsigned allocated; /* Total number of blocks allocated */
size_t list_mem; /* Amount of memory in block on free list */
const char *name; /* Name of the type */
int maxelem; /* Maximum number of elements in an array */
@@ -423,6 +427,8 @@ H5_DLL herr_t H5FL_garbage_coll(void);
H5_DLL herr_t H5FL_set_free_list_limits(int reg_global_lim, int reg_list_lim,
int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim,
int fac_global_lim, int fac_list_lim);
+H5_DLL herr_t H5FL_get_free_list_sizes(size_t *reg_size, size_t *arr_size,
+ size_t *blk_size, size_t *fac_size);
H5_DLL int H5FL_term_interface(void);
#endif
diff --git a/src/H5MM.c b/src/H5MM.c
index 94bd542..0add640 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -108,8 +108,8 @@ static H5MM_block_t H5MM_block_head_s;
/* Statistics about block allocations */
static unsigned long long H5MM_total_alloc_bytes_s = 0;
-static unsigned long long H5MM_curr_alloc_bytes_s = 0;
-static unsigned long long H5MM_peak_alloc_bytes_s = 0;
+static size_t H5MM_curr_alloc_bytes_s = 0;
+static size_t H5MM_peak_alloc_bytes_s = 0;
static size_t H5MM_max_block_size_s = 0;
static size_t H5MM_total_alloc_blocks_count_s = 0;
static size_t H5MM_curr_alloc_blocks_count_s = 0;
@@ -235,7 +235,7 @@ H5MM_final_sanity_check(void)
HDassert(H5MM_block_head_s.prev == &H5MM_block_head_s);
#ifdef H5MM_PRINT_MEMORY_STATS
HDfprintf(stderr, "%s: H5MM_total_alloc_bytes_s = %llu\n", __func__, H5MM_total_alloc_bytes_s);
- HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %llu\n", __func__, H5MM_peak_alloc_bytes_s);
+ HDfprintf(stderr, "%s: H5MM_peak_alloc_bytes_s = %zu\n", __func__, H5MM_peak_alloc_bytes_s);
HDfprintf(stderr, "%s: H5MM_max_block_size_s = %zu\n", __func__, H5MM_max_block_size_s);
HDfprintf(stderr, "%s: H5MM_total_alloc_blocks_count_s = %zu\n", __func__, H5MM_total_alloc_blocks_count_s);
HDfprintf(stderr, "%s: H5MM_peak_alloc_blocks_count_s = %zu\n", __func__, H5MM_peak_alloc_blocks_count_s);
@@ -625,3 +625,46 @@ H5MM_memcpy(void *dest, const void *src, size_t n)
} /* end H5MM_memcpy() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5MM_get_alloc_stats
+ *
+ * Purpose: Gets the memory allocation statistics for the library, if the
+ * H5_MEMORY_ALLOC_SANITY_CHECK macro is defined. If the macro is not
+ * defined, zeros are returned. These statistics are global for the
+ * entire library.
+ *
+ * Parameters:
+ * H5_alloc_stats_t *stats; OUT: Memory allocation statistics
+ *
+ * Return: Success: non-negative
+ * Failure: negative
+ *
+ * Programmer: Quincey Koziol
+ * Saturday, March 7, 2020
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5MM_get_alloc_stats(H5_alloc_stats_t *stats)
+{
+ FUNC_ENTER_NOAPI_NOERR
+
+#if defined H5_MEMORY_ALLOC_SANITY_CHECK
+ if(stats) {
+ stats->total_alloc_bytes = H5MM_total_alloc_bytes_s;
+ stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s;
+ stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s;
+ stats->max_block_size = H5MM_max_block_size_s;
+ stats->total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s;
+ stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s;
+ stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s;
+ } /* end if */
+#else /* H5_MEMORY_ALLOC_SANITY_CHECK */
+ if(stats)
+ HDmemset(stats, 0, sizeof(H5_alloc_stats_t));
+#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5MM_get_alloc_stats() */
+
diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h
index 240b931..0787eb2 100644
--- a/src/H5MMprivate.h
+++ b/src/H5MMprivate.h
@@ -47,6 +47,7 @@ H5_DLL char *H5MM_strdup(const char *s);
H5_DLL void *H5MM_xfree(void *mem);
H5_DLL void *H5MM_xfree_const(const void *mem);
H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n);
+H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats);
#if defined H5_MEMORY_ALLOC_SANITY_CHECK
H5_DLL void H5MM_sanity_check_all(void);
H5_DLL void H5MM_final_sanity_check(void);
diff --git a/src/H5TS.c b/src/H5TS.c
index b0cef7f..98eba41 100644
--- a/src/H5TS.c
+++ b/src/H5TS.c
@@ -39,26 +39,26 @@ H5TS_key_t H5TS_cancel_key_g;
#ifndef H5_HAVE_WIN_THREADS
-/* An h5_tid_t is a record of a thread identifier that is
+/* An H5TS_tid_t is a record of a thread identifier that is
* available for reuse.
*/
struct _tid;
-typedef struct _tid h5_tid_t;
+typedef struct _tid H5TS_tid_t;
struct _tid {
- h5_tid_t *next;
+ H5TS_tid_t *next;
uint64_t id;
};
/* Pointer to first free thread ID record or NULL. */
-static h5_tid_t *tid_next_free = NULL;
-static uint64_t tid_next_id = 0;
+static H5TS_tid_t *H5TS_tid_next_free = NULL;
+static uint64_t H5TS_tid_next_id = 0;
-/* Mutual exclusion for access to tid_next_free and tid_next_id. */
-static pthread_mutex_t tid_mtx;
+/* Mutual exclusion for access to H5TS_tid_next_free and H5TS_tid_next_id. */
+static pthread_mutex_t H5TS_tid_mtx;
/* Key for thread-local storage of the thread ID. */
-static H5TS_key_t tid_key;
+static H5TS_key_t H5TS_tid_key;
#endif /* H5_HAVE_WIN_THREADS */
@@ -93,47 +93,85 @@ H5TS_key_destructor(void *key_val)
#ifndef H5_HAVE_WIN_THREADS
-/* When a thread shuts down, put its ID record on the free list. */
+/*--------------------------------------------------------------------------
+ * NAME
+ * H5TS_tid_destructor
+ *
+ * USAGE
+ * H5TS_tid_destructor()
+ *
+ * RETURNS
+ *
+ * DESCRIPTION
+ * When a thread shuts down, put its ID record on the free list.
+ *
+ *--------------------------------------------------------------------------
+ */
static void
-tid_destructor(void *_v)
+H5TS_tid_destructor(void *_v)
{
- h5_tid_t *tid = _v;
+ H5TS_tid_t *tid = _v;
if (tid == NULL)
return;
- /* XXX I can use mutexes in destructors, right? */
/* TBD use an atomic CAS */
- pthread_mutex_lock(&tid_mtx);
- tid->next = tid_next_free;
- tid_next_free = tid;
- pthread_mutex_unlock(&tid_mtx);
+ pthread_mutex_lock(&H5TS_tid_mtx);
+ tid->next = H5TS_tid_next_free;
+ H5TS_tid_next_free = tid;
+ pthread_mutex_unlock(&H5TS_tid_mtx);
}
-/* Initialize for integer thread identifiers. */
+/*--------------------------------------------------------------------------
+ * NAME
+ * H5TS_tid_init
+ *
+ * USAGE
+ * H5TS_tid_init()
+ *
+ * RETURNS
+ *
+ * DESCRIPTION
+ * Initialize for integer thread identifiers.
+ *
+ *--------------------------------------------------------------------------
+ */
static void
-tid_init(void)
+H5TS_tid_init(void)
{
- pthread_mutex_init(&tid_mtx, NULL);
- pthread_key_create(&tid_key, tid_destructor);
+ pthread_mutex_init(&H5TS_tid_mtx, NULL);
+ pthread_key_create(&H5TS_tid_key, H5TS_tid_destructor);
}
-/* Return an integer identifier, ID, for the current thread satisfying the
- * following properties:
+/*--------------------------------------------------------------------------
+ * NAME
+ * H5TS_thread_id
*
- * 1 1 <= ID <= UINT64_MAX
- * 2 ID is constant over the thread's lifetime.
- * 3 No two threads share an ID during their lifetimes.
- * 4 A thread's ID is available for reuse as soon as it is joined.
+ * USAGE
+ * uint64_t id = H5TS_thread_id()
+ *
+ * RETURNS
+ * Return an integer identifier, ID, for the current thread.
+ *
+ * DESCRIPTION
+ * The ID satisfies the following properties:
+ *
+ * 1 1 <= ID <= UINT64_MAX
+ * 2 ID is constant over the thread's lifetime.
+ * 3 No two threads share an ID during their lifetimes.
+ * 4 A thread's ID is available for reuse as soon as it is joined.
*
- * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not built
- * with thread safety or if an error prevents it from assigning an ID.
+ * ID 0 is reserved. H5TS_thread_id() returns 0 if the library was not
+ * built with thread safety or if an error prevents it from assigning an
+ * ID.
+ *
+ *--------------------------------------------------------------------------
*/
uint64_t
H5TS_thread_id(void)
{
- h5_tid_t *tid = pthread_getspecific(tid_key);
- h5_tid_t proto_tid;
+ H5TS_tid_t *tid = pthread_getspecific(H5TS_tid_key);
+ H5TS_tid_t proto_tid;
/* An ID is already assigned. */
if (tid != NULL)
@@ -146,14 +184,14 @@ H5TS_thread_id(void)
* point `tid` at `proto_tid` if we need to allocate some
* memory.
*/
- pthread_mutex_lock(&tid_mtx);
- if ((tid = tid_next_free) != NULL)
- tid_next_free = tid->next;
- else if (tid_next_id != UINT64_MAX) {
+ pthread_mutex_lock(&H5TS_tid_mtx);
+ if ((tid = H5TS_tid_next_free) != NULL)
+ H5TS_tid_next_free = tid->next;
+ else if (H5TS_tid_next_id != UINT64_MAX) {
tid = &proto_tid;
- tid->id = ++tid_next_id;
+ tid->id = ++H5TS_tid_next_id;
}
- pthread_mutex_unlock(&tid_mtx);
+ pthread_mutex_unlock(&H5TS_tid_mtx);
/* If a prototype ID record was established, copy it to the heap. */
if (tid == &proto_tid) {
@@ -168,8 +206,8 @@ H5TS_thread_id(void)
* to it.
*/
tid->next = NULL;
- if (pthread_setspecific(tid_key, tid) != 0) {
- tid_destructor(tid);
+ if (pthread_setspecific(H5TS_tid_key, tid) != 0) {
+ H5TS_tid_destructor(tid);
return 0;
}
@@ -213,7 +251,7 @@ H5TS_pthread_first_thread_init(void)
H5_g.init_lock.lock_count = 0;
/* Initialize integer thread identifiers. */
- tid_init();
+ H5TS_tid_init();
/* initialize key for thread-specific error stacks */
pthread_key_create(&H5TS_errstk_key_g, H5TS_key_destructor);
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 29fd582..2b1283e 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -3213,7 +3213,7 @@ H5T__conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
* necessary. If the SEQ_LEN is 0, allocate a minimal size buffer.
*/
if(!seq_len && !conv_buf) {
- conv_buf_size = ((1 / H5T_VLEN_MIN_CONF_BUF_SIZE) + 1) * H5T_VLEN_MIN_CONF_BUF_SIZE;
+ conv_buf_size = H5T_VLEN_MIN_CONF_BUF_SIZE;
if(NULL == (conv_buf = H5FL_BLK_CALLOC(vlen_seq, conv_buf_size)))
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for type conversion")
} /* end if */
diff --git a/src/H5VL.c b/src/H5VL.c
index 18fd3d6..f83baf2 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -663,7 +663,7 @@ done:
/*---------------------------------------------------------------------------
* Function: H5VLobject
*
- * Purpose: Retrieve the object pointer associated with an hid_t for a.
+ * Purpose: Retrieve the object pointer associated with an hid_t for a
* VOL object.
*
* Note: This routine is mainly targeted toward unwrapping objects for
diff --git a/src/H5public.h b/src/H5public.h
index 3312cf4..f592ab9 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -378,6 +378,19 @@ typedef struct H5O_token_t {
uint8_t __data[H5O_MAX_TOKEN_SIZE];
} H5O_token_t;
+/*
+ * Allocation statistics info struct
+ */
+typedef struct H5_alloc_stats_t {
+ unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */
+ size_t curr_alloc_bytes; /* Current # of bytes allocated */
+ size_t peak_alloc_bytes; /* Peak # of bytes allocated */
+ size_t max_block_size; /* Largest block allocated */
+ size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */
+ size_t curr_alloc_blocks_count; /* Current # of blocks allocated */
+ size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */
+} H5_alloc_stats_t;
+
/* Functions in H5.c */
H5_DLL herr_t H5open(void);
H5_DLL herr_t H5close(void);
@@ -386,6 +399,9 @@ H5_DLL herr_t H5garbage_collect(void);
H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim,
int arr_global_lim, int arr_list_lim, int blk_global_lim,
int blk_list_lim);
+H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size,
+ size_t *blk_size, size_t *fac_size);
+H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats);
H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
unsigned *relnum);
H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum,
diff --git a/src/H5trace.c b/src/H5trace.c
index 7168d5d..03d9e7c 100644
--- a/src/H5trace.c
+++ b/src/H5trace.c
@@ -155,7 +155,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...)
} /* end if */
/* Get time for event */
- if(H5_DBL_ABS_EQUAL(first_time.etime, 0.0))
+ if(H5_DBL_ABS_EQUAL(first_time.etime, (double)0.0f))
H5_timer_begin(&first_time);
if(H5_debug_g.ttimes)
H5_timer_begin(&event_time);
diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in
index 1591bed..0c2be75 100644
--- a/src/libhdf5.settings.in
+++ b/src/libhdf5.settings.in
@@ -39,7 +39,7 @@ Languages:
H5_CPPFLAGS: @H5_CPPFLAGS@
AM_CPPFLAGS: @AM_CPPFLAGS@
C Flags: @CFLAGS@
- H5 C Flags: @H5_CFLAGS@
+ H5 C Flags: @H5_CFLAGS@ @H5_ECFLAGS@
AM C Flags: @AM_CFLAGS@
Shared C Library: @enable_shared@
Static C Library: @enable_static@
diff --git a/test/gen_bounds.c b/test/gen_bounds.c
index 7b670f7..fe05a1e 100644
--- a/test/gen_bounds.c
+++ b/test/gen_bounds.c
@@ -27,8 +27,61 @@
* that they can or cannot read particular file format.
*/
+/*
+ * Add two routines gen_ref_files() and gen_sel_files() to generate the
+ * following test files:
+ *
+ * (1) gen_ref_files():
+ * bounds_ref_earliest_latest.h5
+ * bounds_ref_latest_latest.h5
+ * bounds_ref_v110_v110.h5
+ * bounds_ref_v18_v18.h5
+ * (1) gen_sel_files():
+ * bounds_sel_earliest_latest.h5
+ * bounds_sel_latest_latest.h5
+ * bounds_sel_v112_v112.h5
+ * bounds_sel_v110_v110.h5
+ *
+ * These test files will be copied to 1.12, 1.10 and 1.8 libraries for
+ * compatibility testing.
+ */
#include "h5test.h"
+/*
+ * Defines for gen_ref_files()
+ */
+/* File names used for references */
+#define FILENAME_REF_E_L "bounds_ref_earliest_latest.h5"
+#define FILENAME_REF_L_L "bounds_ref_latest_latest.h5"
+#define FILENAME_REF_V112_V112 "bounds_ref_v112_v112.h5"
+#define FILENAME_REF_V110_V110 "bounds_ref_v110_v110.h5"
+#define FILENAME_REF_V18_V18 "bounds_ref_v18_v18.h5"
+
+/* Dataset names for references */
+#define REVISED_REFS_DSET "Revised_refs_dset"
+#define OLD_REF_OBJ_DSET "Old_ref_object_dset"
+#define OLD_REF_REG_DSET "Old_ref_region_dset"
+
+#define GROUP "Group"
+#define ATTR "Attr"
+#define DATASET "Dataset"
+#define POWER32 4294967296 /* 2^32 */
+
+/*
+ * Defines for gen_sel_files()
+ */
+/* File names for hyperslab/point selections */
+#define FILENAME_SEL_E_L "bounds_sel_earliest_latest.h5"
+#define FILENAME_SEL_L_L "bounds_sel_latest_latest.h5"
+#define FILENAME_SEL_V112_V112 "bounds_sel_v112_v112.h5"
+#define FILENAME_SEL_V110_V110 "bounds_sel_v110_v110.h5"
+
+/* Dataset names for hyperslab/point selections */
+#define SEL_EX_REG_DSET "Sel_ex32_reg_dset"
+#define SEL_EX_IRR_DSET "Sel_ex32_irr_dset"
+#define SEL_EX_PT_DSET "Sel_ex32_pt_dset"
+
+
/***********************************************************************
* gen_earliest_latest() creates file "bounds_earliest_latest.h5"
*
@@ -594,6 +647,461 @@ error:
return FAIL;
} /* gen_v18_v18 */
+/***********************************************************************
+ * gen_sel_files() is used to create the following test files:
+ * bounds_sel_earliest_latest.h5
+ * bounds_sel_latest_latest.h5
+ * bounds_sel_v112_v112.h5
+ * bounds_sel_v110_v110.h5
+ *
+ * File contents for:
+ * --bounds_sel_earliest_latest.h5
+ * --bounds_sel_latest_latest.h5
+ * --bounds_sel_v112_v112.h5
+ * --each file contains 3 datasets with old region reference type
+ * (1) Sel_ex32_reg_dset:
+ * --regular hyperslab selection exceeding 32 bits integer limit
+ * (2) Sel_ex32_irr_dset:
+ * --irregular hyperslab selection exceeding 32 bits integer limit
+ * (3) Sel_ex32_pt_dset:
+ * --point selection exceeding 32 bits integer limit
+ *
+ * File contents for:
+ * --bounds_ref_v110_v110.h5
+ * (1) Sel_ex32_reg_dset: a dataset with old region reference type
+ * --regular hyperslab selection exceeding 32 bits integer limit
+ * (2) Sel_ex32_irr_dset: does not exist, cannot be created
+ * (3) Sel_ex32_pt_dset: does not exist, cannot be created
+ *
+ * Return: SUCCEED/FAIL
+ *
+ ***********************************************************************/
+static herr_t gen_sel_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound)
+{
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hsize_t numparticles = 8388608;
+ hsize_t total_particles = numparticles * 513;
+ hsize_t vdsdims[1] = {total_particles}; /* Dataset dimension size */
+ hsize_t coord[4]; /* Point selection */
+ hsize_t ref_start; /* Starting location of hyperslab */
+ hsize_t ref_stride; /* Stride of hyperslab */
+ hsize_t ref_count; /* Element count of hyperslab */
+ hsize_t ref_block; /* Block size of hyperslab */
+ hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */
+ hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */
+ hsize_t ref_dims[1] = {1}; /* Dimension for reference dataset */
+ hdset_reg_ref_t ref_wbuf[1]; /* Buffer for dataset region reference */
+
+ /*
+ * Create test file, attribute, group and dataset
+ */
+
+ /* Create the test file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create a dataset */
+ if((sid = H5Screate_simple(1, vdsdims, NULL)) < 0)
+ TEST_ERROR;
+
+ if((did = H5Dcreate2(fid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ /* Create file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ TEST_ERROR;
+
+ /* Set to use the low/high bounds in fapl */
+ if(H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0)
+ TEST_ERROR;
+
+ /* Open the file with fapl */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR;
+
+ /* Open the dataset */
+ if((did = H5Dopen2(fid, DATASET, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Get the dataset's dataspace */
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
+
+ /* Create dataspace for the reference dataset */
+ ref_dims[0] = 1;
+ if((ref_sid = H5Screate_simple(1, ref_dims, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Generate regular hyperslab exceeding 32 */
+ ref_start = 0;
+ ref_count = 2;
+ ref_block = 4;
+ ref_stride = POWER32;
+
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &ref_start, &ref_stride, &ref_count, &ref_block) < 0)
+ TEST_ERROR;
+
+ /* Should succeed for v110 and above */
+ if(high_bound >= H5F_LIBVER_V110) {
+
+ /* Create the first reference */
+ if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0)
+ TEST_ERROR;
+
+ /* Create the reference datset */
+ if((ref_did = H5Dcreate2(fid, SEL_EX_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Write to the reference datset */
+ if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+ }
+
+ /* Generate irregular hyperslab exceeding 32 */
+ ref_start = 8;
+ ref_count = 5;
+ ref_block = 2;
+ ref_stride = POWER32;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_OR, &ref_start, &ref_stride, &ref_count, &ref_block) < 0)
+ TEST_ERROR;
+
+ /* Should succeed for v112 and above */
+ if(high_bound >= H5F_LIBVER_V112) {
+
+ /* Create the second reference */
+ if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0)
+ TEST_ERROR;
+
+ /* Create the reference datset */
+ if((ref_did = H5Dcreate2(fid, SEL_EX_IRR_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Write to the reference datset */
+ if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+ }
+
+ /* Generate point selection exceeding 32 */
+ coord[0] = 5;
+ coord[1] = 15;
+ coord[2] = POWER32 + 1;
+ coord[3] = 19;
+
+ if(H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)4, coord) < 0)
+ TEST_ERROR;
+
+ /* Should succeed for v112 and above */
+ if(high_bound >= H5F_LIBVER_V112) {
+
+ /* Create the third reference */
+ if(H5Rcreate(&ref_wbuf[0], fid, DATASET, H5R_DATASET_REGION, sid) < 0)
+ TEST_ERROR;
+
+ /* Create the reference datset */
+ if((ref_did = H5Dcreate2(fid, SEL_EX_PT_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Write to the reference datset */
+ if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_wbuf) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+ }
+
+ /* Closing */
+ if(H5Sclose(ref_sid) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(did) < 0)
+ TEST_ERROR;
+
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR;
+
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(ref_did);
+ H5Sclose(ref_sid);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ } H5E_END_TRY;
+
+ return FAIL;
+
+} /* gen_sel_files() */
+
+/***********************************************************************
+ * gen_ref_files() is used to create the following test files:
+ * bounds_ref_earliest_latest.h5
+ * bounds_ref_latest_latest.h5
+ * bounds_ref_v110_v110.h5
+ * bounds_ref_v18_v18.h5
+ *
+ * File contents for:
+ * --bounds_ref_earliest_latest.h5
+ * --bounds_ref_latest_latest.h5
+ * --bounds_ref_v112_v112.h5
+ * (1) Revised_refs_dset: a dataset created with the revised reference type
+ * --attribute reference
+ * --object reference
+ * --dataset region reference
+ * (2) Old_ref_object_dset:
+ * --a dataset created with the old object reference type
+ * (3) Old_ref_region_dset:
+ * --a dataset created with the old dataset region reference type
+ *
+ * File contents for:
+ * --bounds_ref_v110_v110.h5
+ * --bounds_ref_v18_v18.h5
+ * (1) Old_ref_object_dset:
+ * --a dataset created with the old object reference type
+ * (2) Old_ref_region_dset:
+ * --a dataset created with the old dataset region reference type
+ *
+ * Return: SUCCEED/FAIL
+ *
+ ***********************************************************************/
+static herr_t gen_ref_files(const char *filename, H5F_libver_t low_bound, H5F_libver_t high_bound)
+{
+ hid_t fid = H5I_INVALID_HID; /* File ID */
+ hid_t gid = H5I_INVALID_HID; /* Group ID */
+ hid_t fapl = H5I_INVALID_HID; /* File access property list */
+ hid_t aid = H5I_INVALID_HID; /* Attribute ID */
+ hid_t asid = H5I_INVALID_HID; /* Dataspace ID for attribute */
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hid_t did = H5I_INVALID_HID; /* Dataset ID */
+ hsize_t dims[1] = {100}; /* Dimension size */
+ unsigned *dwbuf = NULL; /* Buffer for writing data */
+ hid_t ref_sid = H5I_INVALID_HID; /* Dataspace ID for the reference dataset */
+ hid_t ref_did = H5I_INVALID_HID; /* Dataset ID for the reference dataset */
+ hsize_t rev_ref_dims[1] = {3}; /* Dimension size for the reference dataset */
+ H5R_ref_t rev_ref_wbuf[3]; /* Buffer for storing the revised references */
+ hobj_ref_t old_ref_obj_wbuf[1]; /* Buffer for storing the old reference object */
+ hdset_reg_ref_t old_ref_reg_wbuf[1]; /* Buffer for storing the old dataset region reference */
+ hsize_t old_ref_dims[] = {1}; /* Dimension size for the reference dataset */
+ hsize_t start[1]; /* Starting location of hyperslab */
+ hsize_t stride[1]; /* Stride of hyperslab */
+ hsize_t count[1]; /* Element count of hyperslab */
+ hsize_t block[1]; /* Block size of hyperslab */
+ unsigned i; /* Local index variable */
+
+ /*
+ * Create test file, attribute, group and dataset
+ */
+
+ if((dwbuf = HDcalloc(sizeof(unsigned), 100)) == NULL)
+ TEST_ERROR;
+
+ /* Create the test file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create dataspace for the attribute */
+ if((asid = H5Screate(H5S_SCALAR)) < 0)
+ TEST_ERROR;
+
+ /* Create an attribute to the root group */
+ if((aid = H5Acreate2(fid, ATTR, H5T_NATIVE_UINT, asid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create a group */
+ if((gid = H5Gcreate2(fid, GROUP, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create dataspace for the dataset */
+ if((sid = H5Screate_simple(1, dims, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Create a dataset in the group */
+ if((did = H5Dcreate2(gid, DATASET, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Initialize data to write */
+ for(i = 0; i < 100; i++)
+ dwbuf[i] = i * 3;
+
+ /* Write data to disk */
+ if(H5Dwrite(did, H5T_NATIVE_UINT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dwbuf) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(did) < 0)
+ TEST_ERROR;
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR;
+ if(H5Sclose(asid) < 0)
+ TEST_ERROR;
+ if(H5Aclose(aid) < 0)
+ TEST_ERROR;
+ if(H5Gclose(gid) < 0)
+ TEST_ERROR;
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ if(dwbuf) {
+ HDfree(dwbuf);
+ dwbuf = NULL;
+ }
+
+ /* Create file access property list */
+ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR;
+
+ /* Set to use the low/high bounds in fapl */
+ if(H5Pset_libver_bounds(fapl, low_bound, high_bound) < 0)
+ TEST_ERROR;
+
+ /* Open the file with fapl */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl)) <0)
+ TEST_ERROR;
+
+ /*
+ * Create the revised and old references in the file
+ */
+
+ /* Retrieve dataspace for the existing dataset */
+ if((did = H5Dopen2(fid, "/Group/Dataset", H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if((sid = H5Dget_space(did)) < 0)
+ TEST_ERROR;
+
+ /* Select 15 2x1 hyperslabs for the dataset region reference */
+ start[0] = 2;
+ stride[0] = 5;
+ count[0] = 15;
+ block[0] = 2;
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, start, stride, count, block) < 0)
+ TEST_ERROR;
+
+
+ if(high_bound >= H5F_LIBVER_V112) {
+
+ /* Create dataspace for the reference dataset */
+ if((ref_sid = H5Screate_simple(1, rev_ref_dims, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Create a dataset with the revised reference type */
+ ref_did = H5Dcreate2(fid, REVISED_REFS_DSET, H5T_STD_REF, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Store the reference to "Attr" */
+ if(H5Rcreate_attr(fid, "/", "Attr", H5P_DEFAULT, &rev_ref_wbuf[0]) < 0)
+ TEST_ERROR;
+
+ /* Store the reference to /Group */
+ if(H5Rcreate_object(fid, "/Group", H5P_DEFAULT, &rev_ref_wbuf[1]) < 0)
+ TEST_ERROR;
+
+ /* Store the dataset region referenced to /Group/Dataset */
+ if(H5Rcreate_region(fid, "/Group/Dataset", sid, H5P_DEFAULT, &rev_ref_wbuf[2]) < 0)
+ TEST_ERROR;
+
+ /* Write to the reference dataset */
+ if(H5Dwrite(ref_did, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rev_ref_wbuf) < 0)
+ TEST_ERROR;
+
+ /* Destroy references */
+ for(i = 0; i < 3; i++)
+ if(H5Rdestroy(&rev_ref_wbuf[i]) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+
+ if(H5Sclose(ref_sid) < 0)
+ TEST_ERROR;
+ }
+
+ /* Create dataspace for the reference dataset */
+ if((ref_sid = H5Screate_simple(1, old_ref_dims, NULL)) < 0)
+ TEST_ERROR;
+
+ /* Create a dataset with the old object reference type */
+ if((ref_did = H5Dcreate2(fid, OLD_REF_OBJ_DSET, H5T_STD_REF_OBJ, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create reference to /Group */
+ if(H5Rcreate(&old_ref_obj_wbuf[0], fid, "/Group", H5R_OBJECT, -1) < 0)
+ TEST_ERROR;
+
+ /* Write to the reference dataset */
+ if(H5Dwrite(ref_did, H5T_STD_REF_OBJ, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_obj_wbuf) < 0)
+ TEST_ERROR;
+
+ /* Close the dataset */
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+
+
+ /* Create a dataset with the old dataset region reference type */
+ if((ref_did = H5Dcreate2(fid, OLD_REF_REG_DSET, H5T_STD_REF_DSETREG, ref_sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* Create dataset region reference */
+ if(H5Rcreate(&old_ref_reg_wbuf[0], fid, "/Group/Dataset", H5R_DATASET_REGION, sid) < 0)
+ TEST_ERROR;
+
+ /* Write selection to the reference dataset */
+ if(H5Dwrite(ref_did, H5T_STD_REF_DSETREG, H5S_ALL, H5S_ALL, H5P_DEFAULT, old_ref_reg_wbuf) < 0)
+ TEST_ERROR;
+
+ /* Closing */
+ if(H5Dclose(ref_did) < 0)
+ TEST_ERROR;
+ if(H5Sclose(ref_sid) < 0)
+ TEST_ERROR;
+
+ if(H5Dclose(did) < 0)
+ TEST_ERROR;
+ if(H5Sclose(sid) < 0)
+ TEST_ERROR;
+ if(H5Pclose(fapl) < 0)
+ TEST_ERROR;
+ if(H5Fclose(fid) < 0)
+ TEST_ERROR;
+
+ return SUCCEED;
+
+error:
+ H5E_BEGIN_TRY {
+ H5Dclose(ref_did);
+ H5Sclose(ref_sid);
+ H5Dclose(did);
+ H5Sclose(sid);
+ H5Pclose(fapl);
+ H5Fclose(fid);
+ HDfree(dwbuf);
+ } H5E_END_TRY;
+
+ return FAIL;
+
+} /* gen_ref_files() */
+
int main(void)
{
/* Generate file bounds_earliest_latest.h5 */
@@ -611,6 +1119,51 @@ int main(void)
/* Generate file bounds_v18_v18.h5 */
if (gen_v18_v18() < 0) TEST_ERROR;
+
+ /*
+ * Files generated via gen_ref_files()
+ */
+
+ /* Generate bounds_ref_earliest_latest.h5 */
+ if(gen_ref_files(FILENAME_REF_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_ref_latest_latest.h5 */
+ if(gen_ref_files(FILENAME_REF_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_ref_v112_v112.h5 */
+ if(gen_ref_files(FILENAME_REF_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_ref_v110_v110.h5 */
+ if(gen_ref_files(FILENAME_REF_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_ref_v18_v18.h5 */
+ if(gen_ref_files(FILENAME_REF_V18_V18, H5F_LIBVER_V18, H5F_LIBVER_V18) < 0)
+ TEST_ERROR;
+
+ /*
+ * Files generated via gen_sel_files()
+ */
+
+ /* Generate bounds_sel_earliest_latest.h5 */
+ if(gen_sel_files(FILENAME_SEL_E_L, H5F_LIBVER_EARLIEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_sel_latest_latest.h5 */
+ if(gen_sel_files(FILENAME_SEL_L_L, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_sel_v112_v112.h5 */
+ if(gen_sel_files(FILENAME_SEL_V112_V112, H5F_LIBVER_V112, H5F_LIBVER_V112) < 0)
+ TEST_ERROR;
+
+ /* Generate bounds_sel_v110_v110.h5 */
+ if(gen_sel_files(FILENAME_SEL_V110_V110, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0)
+ TEST_ERROR;
+
return EXIT_SUCCESS;
error:
diff --git a/test/tmisc.c b/test/tmisc.c
index 0ea9c4c..6eb6872 100644
--- a/test/tmisc.c
+++ b/test/tmisc.c
@@ -329,6 +329,14 @@ typedef struct
/* and bad offset values are written to that file for testing */
#define MISC33_FILE "bad_offset.h5"
+/* Definitions for misc. test #35 */
+#define MISC35_SPACE_RANK 3
+#define MISC35_SPACE_DIM1 3
+#define MISC35_SPACE_DIM2 15
+#define MISC35_SPACE_DIM3 13
+#define MISC35_NPOINTS 10
+
+
/****************************************************************
**
** test_misc1(): test unlinking a dataset from a group and immediately
@@ -5684,6 +5692,118 @@ test_misc34(void)
/****************************************************************
**
+** test_misc35(): Check operation of free-list routines
+**
+****************************************************************/
+static void
+test_misc35(void)
+{
+ hid_t sid = H5I_INVALID_HID; /* Dataspace ID */
+ hsize_t dims[] = {MISC35_SPACE_DIM1, MISC35_SPACE_DIM2, MISC35_SPACE_DIM3}; /* Dataspace dims */
+ hsize_t coord[MISC35_NPOINTS][MISC35_SPACE_RANK] = /* Coordinates for point selection */
+ {{0,10, 5},
+ {1, 2, 7},
+ {2, 4, 9},
+ {0, 6,11},
+ {1, 8,13},
+ {2,12, 0},
+ {0,14, 2},
+ {1, 0, 4},
+ {2, 1, 6},
+ {0, 3, 8}};
+ size_t reg_size_start; /* Initial amount of regular memory allocated */
+ size_t arr_size_start; /* Initial amount of array memory allocated */
+ size_t blk_size_start; /* Initial amount of block memory allocated */
+ size_t fac_size_start; /* Initial amount of factory memory allocated */
+ size_t reg_size_final; /* Final amount of regular memory allocated */
+ size_t arr_size_final; /* Final amount of array memory allocated */
+ size_t blk_size_final; /* Final amount of block memory allocated */
+ size_t fac_size_final; /* Final amount of factory memory allocated */
+ H5_alloc_stats_t alloc_stats; /* Memory stats */
+ herr_t ret; /* Return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Free-list API calls"));
+
+ /* Create dataspace */
+ /* (Allocates array free-list nodes) */
+ sid = H5Screate_simple(MISC35_SPACE_RANK, dims, NULL);
+ CHECK(sid, H5I_INVALID_HID, "H5Screate_simple");
+
+ /* Select sequence of ten points */
+ ret = H5Sselect_elements(sid, H5S_SELECT_SET, (size_t)MISC35_NPOINTS, (const hsize_t *)coord);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Close dataspace */
+ ret = H5Sclose(sid);
+ CHECK(ret, FAIL, "H5Sclose");
+
+
+ /* Retrieve initial free list values */
+ ret = H5get_free_list_sizes(&reg_size_start, &arr_size_start, &blk_size_start, &fac_size_start);
+ CHECK(ret, FAIL, "H5get_free_list_sizes");
+
+#if !defined H5_USING_MEMCHECKER
+ /* All the free list values should be >0 */
+ CHECK(reg_size_start, 0, "H5get_free_list_sizes");
+ CHECK(arr_size_start, 0, "H5get_free_list_sizes");
+ CHECK(blk_size_start, 0, "H5get_free_list_sizes");
+ CHECK(fac_size_start, 0, "H5get_free_list_sizes");
+#else /* H5_MEMORY_ALLOC_SANITY_CHECK */
+ /* All the values should be == 0 */
+ VERIFY(reg_size_start, 0, "H5get_free_list_sizes");
+ VERIFY(arr_size_start, 0, "H5get_free_list_sizes");
+ VERIFY(blk_size_start, 0, "H5get_free_list_sizes");
+ VERIFY(fac_size_start, 0, "H5get_free_list_sizes");
+#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */
+
+ /* Garbage collect the free lists */
+ ret = H5garbage_collect();
+ CHECK(ret, FAIL, "H5garbage_collect");
+
+ /* Retrieve free list values again */
+ ret = H5get_free_list_sizes(&reg_size_final, &arr_size_final, &blk_size_final, &fac_size_final);
+ CHECK(ret, FAIL, "H5get_free_list_sizes");
+
+ /* All the free list values should be <= previous values */
+ if(reg_size_final > reg_size_start)
+ ERROR("reg_size_final > reg_size_start");
+ if(arr_size_final > arr_size_start)
+ ERROR("arr_size_final > arr_size_start");
+ if(blk_size_final > blk_size_start)
+ ERROR("blk_size_final > blk_size_start");
+ if(fac_size_final > fac_size_start)
+ ERROR("fac_size_final > fac_size_start");
+
+ /* Retrieve memory allocation statistics */
+ ret = H5get_alloc_stats(&alloc_stats);
+ CHECK(ret, FAIL, "H5get_alloc_stats");
+
+#if defined H5_MEMORY_ALLOC_SANITY_CHECK
+ /* All the values should be >0 */
+ CHECK(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.max_block_size, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats");
+ CHECK(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats");
+#else /* H5_MEMORY_ALLOC_SANITY_CHECK */
+ /* All the values should be == 0 */
+ VERIFY(alloc_stats.total_alloc_bytes, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.curr_alloc_bytes, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.peak_alloc_bytes, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.max_block_size, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.total_alloc_blocks_count, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.curr_alloc_blocks_count, 0, "H5get_alloc_stats");
+ VERIFY(alloc_stats.peak_alloc_blocks_count, 0, "H5get_alloc_stats");
+#endif /* H5_MEMORY_ALLOC_SANITY_CHECK */
+
+} /* end test_misc35() */
+
+
+/****************************************************************
+**
** test_misc(): Main misc. test routine.
**
****************************************************************/
@@ -5731,6 +5851,7 @@ test_misc(void)
test_misc32(); /* Test filter memory allocation functions */
test_misc33(); /* Test to verify that H5HL_offset_into() returns error if offset exceeds heap block */
test_misc34(); /* Test behavior of 0 and NULL in H5MM API calls */
+ test_misc35(); /* Test behavior of free-list & allocation statistics API calls */
} /* test_misc() */
diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt
index 9ce7538..306c033 100644
--- a/tools/lib/CMakeLists.txt
+++ b/tools/lib/CMakeLists.txt
@@ -38,6 +38,9 @@ if (NOT ONLY_SHARED_LIBS)
PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_TOOLS_LIB_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
#target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5_TOOLS_DEBUG)
#target_compile_definitions(${HDF5_TOOLS_LIB_TARGET} PRIVATE H5DIFF_DEBUG)
TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC)
@@ -57,6 +60,9 @@ if (BUILD_SHARED_LIBS)
PRIVATE "${HDF5_TOOLS_LIB_SOURCE_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>"
INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
)
+ target_compile_options(${HDF5_TOOLS_LIBSH_TARGET}
+ PRIVATE "${HDF5_CMAKE_C_FLAGS}"
+ )
target_compile_definitions(${HDF5_TOOLS_LIBSH_TARGET}
PUBLIC "H5_BUILT_AS_DYNAMIC_LIB"
#PRIVATE H5_TOOLS_DEBUG
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index 86726b4..fff0b9a 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -570,14 +570,14 @@ h5diff(const char *fname1, const char *fname2, const char *objname1, const char
*-------------------------------------------------------------------------
*/
/* open file 1 */
- if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ if((file1_id = h5tools_fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) {
parallel_print("h5diff: <%s>: unable to open file\n", fname1);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname1);
} /* end if */
H5TOOLS_DEBUG("file1_id = %s", fname1);
/* open file 2 */
- if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ if((file2_id = h5tools_fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) {
parallel_print("h5diff: <%s>: unable to open file\n", fname2);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "<%s>: unable to open file\n", fname2);
} /* end if */
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 33f1e11..cd915f5 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -29,7 +29,7 @@ int H5tools_INDENT_g = 0;
/* global variables */
-hid_t H5tools_ERR_STACK_g = 0;
+hid_t H5tools_ERR_STACK_g = H5I_INVALID_HID;
hid_t H5tools_ERR_CLS_g = H5I_INVALID_HID;
hid_t H5E_tools_g = H5I_INVALID_HID;
hid_t H5E_tools_min_id_g = H5I_INVALID_HID;
@@ -54,35 +54,41 @@ unsigned long long packed_data_mask; /* mask in which packed bits to display */
int enable_error_stack = 0; /* re-enable error stack; disable=0 enable=1 */
/* sort parameters */
-H5_index_t sort_by = H5_INDEX_NAME; /*sort_by [creation_order | name] */
-H5_iter_order_t sort_order = H5_ITER_INC; /*sort_order [ascending | descending] */
+H5_index_t sort_by = H5_INDEX_NAME; /* sort_by [creation_order | name] */
+H5_iter_order_t sort_order = H5_ITER_INC; /* sort_order [ascending | descending] */
/* module-scoped variables */
static int h5tools_init_g; /* if h5tools lib has been initialized */
-/* Names of VFDs */
-static const char *drivernames[]={
+/* Names of VOL connectors */
+const char *volnames[] = {
+ H5VL_NATIVE_NAME,
+ H5VL_PASSTHRU_NAME,
+};
+
+/* Names of VFDs. These names are always available so that
+ * the tools can emit special messages when a VFD is asked
+ * for by name but is not compiled into the library or is
+ * somehow otherwise not enabled.
+ *
+ */
+const char *drivernames[] = {
"sec2",
+ "direct",
+ "log",
+ "windows",
+ "stdio",
+ "core",
"family",
"split",
"multi",
-#ifdef H5_HAVE_PARALLEL
"mpio",
-#endif /* H5_HAVE_PARALLEL */
+ "ros3",
+ "hdfs",
};
-/* This enum should match the entries in the above drivers_list since they
- * are indexes into the drivers_list array. */
-typedef enum {
- SEC2_IDX = 0
- ,FAMILY_IDX
- ,SPLIT_IDX
- ,MULTI_IDX
-#ifdef H5_HAVE_PARALLEL
- ,MPIO_IDX
-#endif /* H5_HAVE_PARALLEL */
-} driver_idx;
-#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
+#define NUM_VOLS (sizeof(volnames) / sizeof(volnames[0]))
+#define NUM_DRIVERS (sizeof(drivernames) / sizeof(drivernames[0]))
/*-------------------------------------------------------------------------
* Function: h5tools_init
@@ -131,16 +137,19 @@ h5tools_init(void)
void
h5tools_close(void)
{
- H5E_auto2_t tools_func;
- void *tools_edata;
+ H5E_auto2_t tools_func;
+ void *tools_edata;
+
if (h5tools_init_g) {
/* special case where only data is output to stdout */
- if((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
+ if ((rawoutstream == NULL) && rawdatastream && (rawdatastream == stdout))
HDfprintf(rawdatastream, "\n");
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
- if(tools_func!=NULL)
+
+ if (tools_func)
H5Eprint2(H5tools_ERR_STACK_g, rawerrorstream);
+
if (rawattrstream && rawattrstream != stdout) {
if (fclose(rawattrstream))
perror("closing rawattrstream");
@@ -425,189 +434,531 @@ h5tools_set_error_file(const char *fname, int is_bin)
}
/*-------------------------------------------------------------------------
- * Function: h5tools_get_fapl
+ * Function: h5tools_set_vfd_fapl
+ *
+ * Purpose: Given a VFL driver name, sets the appropriate driver on the
+ * specified FAPL.
*
- * Purpose: Get a FAPL for a given VFL driver name.
+ * TODO: Add handling for Windows VFD.
*
* Return: positive - succeeded
* negative - failed
*-------------------------------------------------------------------------
*/
-static hid_t
-h5tools_get_fapl(hid_t fapl, const char *driver, unsigned *drivernum)
+static herr_t
+h5tools_set_vfd_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info)
{
- hid_t new_fapl = H5I_INVALID_HID; /* Copy of file access property list passed in, or new property list */
herr_t ret_value = SUCCEED;
- /* Make a copy of the FAPL, for the file open call to use, eventually */
- if (fapl == H5P_DEFAULT) {
- if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pcreate failed");
- } /* end if */
- else {
- if ((new_fapl = H5Pcopy(fapl)) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pcopy failed");
- } /* end else */
-
- /* Determine which driver the user wants to open the file with. Try
- * that driver. If it can't open it, then fail. */
- if (!HDstrcmp(driver, drivernames[SEC2_IDX])) {
- /* SEC2 driver */
- if (H5Pset_fapl_sec2(new_fapl) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
-
- if (drivernum)
- *drivernum = SEC2_IDX;
+ switch (fapl_info->type) {
+ /* Currently, only retrieving a VFD by name is supported */
+ case VFD_BY_NAME:
+ /* Determine which driver the user wants to open the file with */
+ if (!HDstrcmp(fapl_info->u.name, drivernames[SEC2_VFD_IDX])) {
+ /* SEC2 Driver */
+ if (H5Pset_fapl_sec2(fapl) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[DIRECT_VFD_IDX])) {
+#ifdef H5_HAVE_DIRECT
+ /* Direct Driver */
+ if (H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_direct failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Direct VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[LOG_VFD_IDX])) {
+ unsigned long long log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC;
+
+ /* Log Driver */
+ if (H5Pset_fapl_log(fapl, NULL, log_flags, (size_t) 0) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_sec2 failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[WINDOWS_VFD_IDX])) {
+#ifdef H5_HAVE_WINDOWS
+
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Windows VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[STDIO_VFD_IDX])) {
+ /* Stdio Driver */
+ if (H5Pset_fapl_stdio(fapl) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[CORE_VFD_IDX])) {
+ /* Core Driver */
+ if (H5Pset_fapl_core(fapl, (size_t) H5_MB, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_stdio failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[FAMILY_VFD_IDX])) {
+ /* FAMILY Driver */
+
+ /* Set member size to be 0 to indicate the current first member size
+ * is the member size.
+ */
+ if (H5Pset_fapl_family(fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[SPLIT_VFD_IDX])) {
+ /* SPLIT Driver */
+ if (H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[MULTI_VFD_IDX])) {
+ /* MULTI Driver */
+ if (H5Pset_fapl_multi(fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed");
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[MPIO_VFD_IDX])) {
+#ifdef H5_HAVE_PARALLEL
+ int mpi_initialized, mpi_finalized;
+
+ /* MPI-I/O Driver */
+
+ /* check if MPI is available. */
+ MPI_Initialized(&mpi_initialized);
+ MPI_Finalized(&mpi_finalized);
+
+ if (mpi_initialized && !mpi_finalized) {
+ if (H5Pset_fapl_mpio(fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed");
+ } /* end if */
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "MPI-I/O VFD is not enabled");
+#endif /* H5_HAVE_PARALLEL */
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ if (!fapl_info->info)
+ H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD info is invalid");
+ if (H5Pset_fapl_ros3(fapl, (H5FD_ros3_fapl_t *)fapl_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_ros3() failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "Read-only S3 VFD is not enabled");
+#endif
+ }
+ else if (!HDstrcmp(fapl_info->u.name, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ if (!fapl_info->info)
+ H5TOOLS_GOTO_ERROR(FAIL, "HDFS VFD info is invalid");
+ if (H5Pset_fapl_hdfs(fapl, (H5FD_hdfs_fapl_t *)fapl_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_hdfs() failed");
+#else
+ H5TOOLS_GOTO_ERROR(FAIL, "The HDFS VFD is not enabled");
+#endif
+ }
+ else
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD name");
+
+ break;
+
+ case VOL_BY_NAME:
+ case VOL_BY_ID:
+ default:
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid VFD retrieval type");
}
- else if (!HDstrcmp(driver, drivernames[FAMILY_IDX])) {
- /* FAMILY Driver */
- /* Set member size to be 0 to indicate the current first member size
- * is the member size.
- */
- if (H5Pset_fapl_family(new_fapl, (hsize_t) 0, H5P_DEFAULT) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_family failed");
+done:
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_set_vol_fapl
+ *
+ * Purpose: Given a VOL connector name or ID, sets the appropriate
+ * connector on the specified FAPL.
+ *
+ * Return: positive - succeeded
+ * negative - failed
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+h5tools_set_vol_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info)
+{
+ htri_t connector_is_registered;
+ hid_t connector_id = H5I_INVALID_HID;
+ herr_t ret_value = SUCCEED;
+
+ switch (fapl_info->type) {
+ case VOL_BY_NAME:
+ /* Retrieve VOL connector by name */
+ if ((connector_is_registered = H5VLis_connector_registered_by_name(fapl_info->u.name)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
+ if (connector_is_registered) {
+ if ((connector_id = H5VLget_connector_id_by_name(fapl_info->u.name)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
+ }
+ else {
+ /* Check for VOL connectors that ship with the library */
+ if (!HDstrcmp(fapl_info->u.name, H5VL_NATIVE_NAME)) {
+ connector_id = H5VL_NATIVE;
+ }
+ else if (!HDstrcmp(fapl_info->u.name, H5VL_PASSTHRU_NAME)) {
+ connector_id = H5VL_PASSTHRU;
+ }
+ else {
+ if ((connector_id = H5VLregister_connector_by_name(fapl_info->u.name, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
+ }
+ }
- if (drivernum)
- *drivernum = FAMILY_IDX;
+ break;
+
+ case VOL_BY_ID:
+ /* Retrieve VOL connector by ID */
+ if ((connector_is_registered = H5VLis_connector_registered_by_value((H5VL_class_value_t) fapl_info->u.id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't check if VOL connector is registered");
+ if (connector_is_registered) {
+ if ((connector_id = H5VLget_connector_id_by_value((H5VL_class_value_t) fapl_info->u.id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't get VOL connector ID");
+ }
+ else {
+ /* Check for VOL connectors that ship with the library */
+ if (fapl_info->u.id == H5VL_NATIVE_VALUE) {
+ connector_id = H5VL_NATIVE;
+ }
+ else if (fapl_info->u.id == H5VL_PASSTHRU_VALUE) {
+ connector_id = H5VL_PASSTHRU;
+ }
+ else {
+ if ((connector_id = H5VLregister_connector_by_value((H5VL_class_value_t) fapl_info->u.id, H5P_DEFAULT)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't register VOL connector");
+ }
+ }
+
+ break;
+
+ case VFD_BY_NAME:
+ default:
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid VOL retrieval type");
}
- else if (!HDstrcmp(driver, drivernames[SPLIT_IDX])) {
- /* SPLIT Driver */
- if (H5Pset_fapl_split(new_fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_split failed");
- if (drivernum)
- *drivernum = SPLIT_IDX;
+ if (H5Pset_vol(fapl, connector_id, fapl_info->info) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "can't set VOL connector on FAPL");
+
+done:
+ if (ret_value < 0) {
+ if (connector_id >= 0 && H5Idec_ref(connector_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to decrement refcount on VOL connector ID");
+ }
+
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_get_fapl
+ *
+ * Purpose: Get a FAPL for a given VFL driver name, VOL connector name
+ * or VOL connector ID.
+ *
+ * Return: positive - succeeded
+ * negative - failed
+ *-------------------------------------------------------------------------
+ */
+hid_t
+h5tools_get_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info)
+{
+ hid_t new_fapl = H5I_INVALID_HID;
+ hid_t ret_value = H5I_INVALID_HID;
+
+ if (fapl < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
+ if (!fapl_info)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL retrieval info");
+
+ /* Make a copy of the FAPL if necessary, or create a FAPL if
+ * H5P_DEFAULT is specified. */
+ if (H5P_DEFAULT == fapl) {
+ if ((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcreate failed");
+ } /* end if */
+ else {
+ if ((new_fapl = H5Pcopy(fapl)) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "H5Pcopy failed");
}
- else if (!HDstrcmp(driver, drivernames[MULTI_IDX])) {
- /* MULTI Driver */
- if (H5Pset_fapl_multi(new_fapl, NULL, NULL, NULL, NULL, TRUE) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_multi failed");
- if(drivernum)
- *drivernum = MULTI_IDX;
+ if (VFD_BY_NAME == fapl_info->type) {
+ if (h5tools_set_vfd_fapl(new_fapl, fapl_info) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VFD on FAPL");
}
-#ifdef H5_HAVE_PARALLEL
- else if(!HDstrcmp(driver, drivernames[MPIO_IDX])) {
- int mpi_initialized, mpi_finalized;
-
- /* MPI-I/O Driver */
- /* check if MPI is available. */
- MPI_Initialized(&mpi_initialized);
- MPI_Finalized(&mpi_finalized);
-
- if(mpi_initialized && !mpi_finalized) {
- if(H5Pset_fapl_mpio(new_fapl, MPI_COMM_WORLD, MPI_INFO_NULL) < 0)
- H5TOOLS_GOTO_ERROR(FAIL, "H5Pset_fapl_mpio failed");
- if(drivernum)
- *drivernum = MPIO_IDX;
- } /* end if */
+ else if (VOL_BY_NAME == fapl_info->type || VOL_BY_ID == fapl_info->type) {
+ if (h5tools_set_vol_fapl(new_fapl, fapl_info) < 0)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to set VOL on FAPL");
}
-#endif /* H5_HAVE_PARALLEL */
else
- ret_value = -1;
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "invalid FAPL retrieval type");
+
+ ret_value = new_fapl;
done:
- if((new_fapl != H5P_DEFAULT) && (ret_value < 0)) {
+ if ((new_fapl >= 0) && (ret_value < 0)) {
H5Pclose(new_fapl);
new_fapl = H5I_INVALID_HID;
}
- return(new_fapl);
+ return ret_value;
+}
+
+/*-------------------------------------------------------------------------
+ * Function: h5tools_get_vfd_name
+ *
+ * Purpose: Given a FAPL, retrieves the name of the VFL driver set on it
+ * if using a native-terminal VOL connector. If a
+ * non-native-terminal VOL connector is set on the FAPL, the
+ * first byte of the returned driver name will be set to the null
+ * terminator.
+ *
+ * Return: SUCCEED/FAIL
+ *-------------------------------------------------------------------------
+ */
+herr_t
+h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size)
+{
+ hid_t fapl_vol_id = H5I_INVALID_HID;
+ herr_t ret_value = SUCCEED;
+
+ if (fapl_id < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid FAPL");
+ if (!drivername)
+ H5TOOLS_GOTO_ERROR(FAIL, "drivername is NULL");
+ if (drivername && !drivername_size)
+ H5TOOLS_GOTO_ERROR(FAIL, "drivername_size must be non-zero");
+
+ /* Initialize the driver name */
+ drivername[0] = '\0';
+
+ if (fapl_id == H5P_DEFAULT)
+ fapl_id = H5P_FILE_ACCESS_DEFAULT;
+
+ /* Retrieve ID of the VOL connector set on the FAPL */
+ if (H5Pget_vol_id(fapl_id, &fapl_vol_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to retrieve VOL ID from FAPL");
+
+ /* TODO: For now, we have no way of determining if an arbitrary
+ * VOL connector is native-terminal. */
+ if (fapl_vol_id == H5VL_NATIVE || fapl_vol_id == H5VL_PASSTHRU) {
+ const char *driver_name;
+ hid_t driver_id;
+
+ if ((driver_id = H5Pget_driver(fapl_id)) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to retrieve VFL driver ID from FAPL");
+
+ if (driver_id == H5FD_SEC2)
+ driver_name = drivernames[SEC2_VFD_IDX];
+#ifdef H5_HAVE_DIRECT
+ else if (driver_id == H5FD_DIRECT)
+ driver_name = drivernames[DIRECT_VFD_IDX];
+#endif
+ else if (driver_id == H5FD_LOG)
+ driver_name = drivernames[LOG_VFD_IDX];
+#ifdef H5_HAVE_WINDOWS
+ else if (driver_id == H5FD_WINDOWS)
+ driver_name = drivernames[WINDOWS_VFD_IDX];
+#endif
+ else if (driver_id == H5FD_STDIO)
+ driver_name = drivernames[STDIO_VFD_IDX];
+ else if (driver_id == H5FD_CORE)
+ driver_name = drivernames[CORE_VFD_IDX];
+ else if (driver_id == H5FD_FAMILY)
+ driver_name = drivernames[FAMILY_VFD_IDX];
+ else if (driver_id == H5FD_MULTI)
+ driver_name = drivernames[MULTI_VFD_IDX];
+#ifdef H5_HAVE_PARALLEL
+ else if (driver_id == H5FD_MPIO)
+ driver_name = drivernames[MPIO_VFD_IDX];
+#endif
+#ifdef H5_HAVE_ROS3_VFD
+ else if (driver_id == H5FD_ROS3)
+ driver_name = drivernames[ROS3_VFD_IDX];
+#endif
+#ifdef H5_HAVE_LIBHDFS
+ else if (driver_id == H5FD_HDFS)
+ driver_name = drivernames[HDFS_VFD_IDX];
+#endif
+ else
+ driver_name = "unknown";
+
+ HDstrncpy(drivername, driver_name, drivername_size);
+ drivername[drivername_size - 1] = '\0';
+ }
+
+done:
+ /* Close retrieved VOL ID */
+ if (fapl_vol_id >= 0)
+ if (H5VLclose(fapl_vol_id) < 0)
+ H5TOOLS_ERROR(FAIL, "failed to close VOL ID");
+
+ return ret_value;
}
/*-------------------------------------------------------------------------
* Function: h5tools_fopen
*
- * Purpose: Loop through the various types of VFL drivers trying to open FNAME.
- * If the HDF5 library is version 1.2 or less, then we have only the SEC2
- * driver to try out. If the HDF5 library is greater than version 1.2,
- * then we have the FAMILY, SPLIT, and MULTI drivers to play with.
+ * Purpose: Opens file FNAME using the specified flags and FAPL.
+ *
+ * The 'use_specific_driver' parameter is used to control the
+ * VFD/VOL connector that this routine uses to open the file
+ * with. If 'use_specific_driver' is set to TRUE, this routine
+ * assumes that the caller has already set a specific VFD or VOL
+ * connector on the given FAPL and will attempt to directly use
+ * the FAPL for opening the file. We assume that the caller knows
+ * what they are doing; if the file is unable to be opened using
+ * that FAPL, this routine will return H5I_INVALID_HID.
*
- * If DRIVER is non-NULL, then it will try to open the file with that
- * driver first. We assume that the user knows what they are doing so, if
- * we fail, then we won't try other file drivers.
+ * However, if 'use_specific_driver' is set to FALSE, this
+ * routine assumes that the caller HAS NOT set a specific VFD or
+ * VOL connector on the given FAPL and will instead loop through
+ * the various available VFL drivers and VOL connectors trying to
+ * open FNAME.
+ *
+ * The list of available VFL drivers is as follows:
+ * - If the HDF5 library is version 1.2 or less, then we have
+ * only the SEC2 driver to try out.
+ * - If the HDF5 library is greater than version 1.2, then we
+ * have the FAMILY, SPLIT, and MULTI drivers to play with.
+ *
+ * The list of available VOL connectors is as follows:
+ * - "Native" VOL connector
+ * - Pass-through VOL connector
*
* Return:
- * On success, returns a file id for the opened file. If DRIVERNAME is
- * non-null then the first DRIVERNAME_SIZE-1 characters of the driver
- * name are copied into the DRIVERNAME array and null terminated.
+ * On success, returns a file ID for the opened file. If DRIVERNAME is
+ * non-null and the native VOL connector is the terminal connector,
+ * then the first DRIVERNAME_SIZE-1 characters of the driver name are
+ * copied into the DRIVERNAME array and null terminated. If the
+ * native VOL connector is NOT the terminal connector, then the first
+ * byte of DRIVERNAME will be set to the null terminator.
*
- * Otherwise, the function returns FAIL. If DRIVERNAME is non-null then
- * the first byte is set to the null terminator.
+ * On failure, the function returns H5I_INVALID_HID and DRIVERNAME
+ * will not be set.
*-------------------------------------------------------------------------
*/
hid_t
-h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, const char *driver,
+h5tools_fopen(const char *fname, unsigned flags, hid_t fapl, hbool_t use_specific_driver,
char *drivername, size_t drivername_size)
{
- unsigned drivernum;
- hid_t fid = FAIL;
- hid_t my_fapl = H5P_DEFAULT;
-
- if (driver && *driver) {
- /* Get the correct FAPL for the given driver */
- if ((my_fapl = h5tools_get_fapl(fapl, driver, &drivernum)) < 0)
- goto done;
-
- /* allow error stack display if enable-error-stack has optional arg number */
- if (enable_error_stack > 1) {
- fid = H5Fopen(fname, flags, my_fapl);
- }
- else {
- H5E_BEGIN_TRY {
- fid = H5Fopen(fname, flags, my_fapl);
- } H5E_END_TRY;
- }
+ hid_t fid = H5I_INVALID_HID;
+ hid_t tmp_vol_fapl = H5I_INVALID_HID;
+ hid_t tmp_vfd_fapl = H5I_INVALID_HID;
+ hid_t used_fapl = H5I_INVALID_HID;
+ unsigned volnum, drivernum;
+ hid_t ret_value = H5I_INVALID_HID;
- if (fid == FAIL)
- goto done;
+ /*
+ * First try to open the file using just the given FAPL. If the
+ * HDF5_VOL_CONNECTOR environment variable has been set, this will
+ * allow us to attempt to open the file using the specified VOL
+ * connector before we go looping through all available ones,
+ * which will override any VOL connector set by use of the
+ * environment variable.
+ */
+ /* Allow error stack display if --enable-error-stack has optional arg number */
+ if (enable_error_stack > 1) {
+ fid = H5Fopen(fname, flags, fapl);
}
else {
- /* Try to open the file using each of the drivers */
- for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
- /* Get the correct FAPL for the given driver */
- if((my_fapl = h5tools_get_fapl(fapl, drivernames[drivernum], NULL)) < 0)
- goto done;
-
- /* allow error stack display if enable-error-stack has optional arg number */
- if (enable_error_stack > 1) {
- fid = H5Fopen(fname, flags, my_fapl);
- }
- else {
- H5E_BEGIN_TRY {
- fid = H5Fopen(fname, flags, my_fapl);
- } H5E_END_TRY;
- }
+ H5E_BEGIN_TRY {
+ fid = H5Fopen(fname, flags, fapl);
+ } H5E_END_TRY;
+ }
- if (fid != FAIL)
- break;
- else {
- /* Close the FAPL */
- H5Pclose(my_fapl);
- my_fapl = H5P_DEFAULT;
- } /* end else */
- }
+ /* If we succeeded in opening the file, we're done. */
+ if (fid >= 0) {
+ used_fapl = fapl;
+ H5TOOLS_GOTO_DONE(fid);
}
- /* Save the driver name */
- if (drivername && drivername_size) {
- if (fid != FAIL) {
- HDstrncpy(drivername, drivernames[drivernum], drivername_size);
- drivername[drivername_size - 1] = '\0';
+ /*
+ * If we failed to open the file and the caller specified 'use_specific_driver'
+ * as TRUE, we should return failure now since the file couldn't be opened with
+ * the VFL driver/VOL connector that was set on the FAPL by the caller.
+ */
+ if (fid < 0 && use_specific_driver)
+ H5TOOLS_GOTO_ERROR(H5I_INVALID_HID, "failed to open file using specified FAPL");
+
+ /*
+ * As a final resort, try to open the file using each of the available
+ * VOL connectors. When the native VOL connector is the current "terminal"
+ * connector being looked at, also try using each of the available VFL drivers.
+ */
+ for (volnum = 0; volnum < NUM_VOLS; volnum++) {
+ h5tools_fapl_info_t vol_info;
+
+ vol_info.type = VOL_BY_NAME;
+ vol_info.info = NULL;
+ vol_info.u.name = volnames[volnum];
+
+ /* Get a FAPL for the current VOL connector */
+ if ((tmp_vol_fapl = h5tools_get_fapl(fapl, &vol_info)) < 0)
+ continue;
+
+ /* TODO: For now, we have no way of determining if an arbitrary
+ * VOL connector is native-terminal. */
+ if (NATIVE_VOL_IDX == volnum) {
+ /*
+ * If using the native VOL connector, or a VOL connector which has the
+ * native connector as its terminal connector, loop through all of the
+ * VFL drivers as well.
+ */
+ for (drivernum = 0; drivernum < NUM_DRIVERS; drivernum++) {
+ h5tools_fapl_info_t vfd_info;
+
+ /* Skip the log VFD as it prints out to standard out
+ * and is fundamentally SEC2 anyway.
+ */
+ if (drivernum == LOG_VFD_IDX)
+ continue;
+
+ vfd_info.type = VFD_BY_NAME;
+ vfd_info.info = NULL;
+ vfd_info.u.name = drivernames[drivernum];
+
+ /* Using the current VOL FAPL as a base, get the correct FAPL for the given VFL driver */
+ if ((tmp_vfd_fapl = h5tools_get_fapl(tmp_vol_fapl, &vfd_info)) < 0)
+ continue;
+
+ if ((fid = h5tools_fopen(fname, flags, tmp_vfd_fapl, TRUE, drivername, drivername_size)) >= 0) {
+ used_fapl = tmp_vfd_fapl;
+ H5TOOLS_GOTO_DONE(fid);
+ }
+ else {
+ /* Close the temporary VFD FAPL */
+ H5Pclose(tmp_vfd_fapl);
+ tmp_vfd_fapl = H5I_INVALID_HID;
+ }
+ }
}
else {
- /*no file opened*/
- drivername[0] = '\0';
+ if ((fid = h5tools_fopen(fname, flags, tmp_vol_fapl, TRUE, drivername, drivername_size)) >= 0) {
+ used_fapl = tmp_vol_fapl;
+ H5TOOLS_GOTO_DONE(fid);
+ }
+ else {
+ /* Close the temporary VOL FAPL */
+ H5Pclose(tmp_vol_fapl);
+ tmp_vol_fapl = H5I_INVALID_HID;
+ }
}
}
+ /* File was unable to be opened at all */
+ ret_value = H5I_INVALID_HID;
+
done:
- if(my_fapl != H5P_DEFAULT)
- H5Pclose(my_fapl);
+ /* Save the driver name if using a native-terminal VOL connector */
+ if (drivername && drivername_size && ret_value >= 0)
+ if (used_fapl >= 0 && h5tools_get_vfd_name(used_fapl, drivername, drivername_size) < 0)
+ H5TOOLS_ERROR(H5I_INVALID_HID, "failed to retrieve name of VFD used to open file");
- return fid;
+ if (tmp_vfd_fapl >= 0)
+ H5Pclose(tmp_vfd_fapl);
+ if (tmp_vol_fapl >= 0)
+ H5Pclose(tmp_vol_fapl);
+
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -1436,10 +1787,10 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
for (block_index = 0; block_index < block_nelmts; block_index++) {
mem = ((unsigned char*)_mem) + block_index * size;
- if((region_id = H5Ropen_object((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((region_id = H5Ropen_object((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) < 0)
H5TOOLS_INFO("H5Ropen_object H5T_STD_REF failed");
else {
- if((region_space = H5Ropen_region((const H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((region_space = H5Ropen_region((H5R_ref_t *)mem, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if (!h5tools_is_zero(mem, H5Tget_size(H5T_STD_REF))) {
region_type = H5Sget_select_type(region_space);
if(region_type == H5S_SEL_POINTS)
diff --git a/tools/lib/h5tools.h b/tools/lib/h5tools.h
index 9440e7a..5244f7be 100644
--- a/tools/lib/h5tools.h
+++ b/tools/lib/h5tools.h
@@ -539,6 +539,52 @@ typedef struct h5tools_context_t {
int display_char; /* */
} h5tools_context_t;
+typedef enum {
+ VFD_BY_NAME,
+ VOL_BY_NAME,
+ VOL_BY_ID
+} h5tools_fapl_info_type_t;
+
+typedef struct h5tools_fapl_info_t {
+ h5tools_fapl_info_type_t type;
+
+ /* Pointer to information to be passed to the driver/connector for its setup */
+ const void *info;
+
+ /* Field specifying either the driver's/connector's name or ID */
+ union {
+ const char *name;
+ long id;
+ } u;
+} h5tools_fapl_info_t;
+
+H5TOOLS_DLLVAR const char *volnames[];
+H5TOOLS_DLLVAR const char *drivernames[];
+
+/* This enum should match the entries in the above 'volnames'
+ * since they are indices into the 'volnames' array. */
+typedef enum {
+ NATIVE_VOL_IDX = 0,
+ PASS_THROUGH_VOL_IDX,
+} vol_idx;
+
+/* This enum should match the entries in the above 'drivernames'
+ * since they are indices into the 'drivernames' array. */
+typedef enum {
+ SEC2_VFD_IDX = 0,
+ DIRECT_VFD_IDX,
+ LOG_VFD_IDX,
+ WINDOWS_VFD_IDX,
+ STDIO_VFD_IDX,
+ CORE_VFD_IDX,
+ FAMILY_VFD_IDX,
+ SPLIT_VFD_IDX,
+ MULTI_VFD_IDX,
+ MPIO_VFD_IDX,
+ ROS3_VFD_IDX,
+ HDFS_VFD_IDX,
+} driver_idx;
+
/* The following include, h5tools_str.h, must be after the
* above stucts are defined. There is a dependency in the following
* include that hasn't been identified yet. */
@@ -591,8 +637,10 @@ H5TOOLS_DLL int h5tools_set_attr_output_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_input_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_output_file(const char *fname, int is_bin);
H5TOOLS_DLL int h5tools_set_error_file(const char *fname, int is_bin);
+H5TOOLS_DLL hid_t h5tools_get_fapl(hid_t fapl, h5tools_fapl_info_t *fapl_info);
+H5TOOLS_DLL herr_t h5tools_get_vfd_name(hid_t fapl_id, char *drivername, size_t drivername_size);
H5TOOLS_DLL hid_t h5tools_fopen(const char *fname, unsigned flags, hid_t fapl,
- const char *driver, char *drivername, size_t drivername_len);
+ hbool_t use_specific_driver, char *drivername, size_t drivername_size);
H5TOOLS_DLL hid_t h5tools_get_little_endian_type(hid_t type);
H5TOOLS_DLL hid_t h5tools_get_big_endian_type(hid_t type);
H5TOOLS_DLL htri_t h5tools_detect_vlen(hid_t tid);
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 96545c8..cd7c3d2 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -2099,11 +2099,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
if(obj) {
if(!obj->recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
- H5Otoken_to_str(type, &oinfo.token, &obj_addr_str);
- h5tools_str_append(buffer,"\"/#%s\"", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(type, &oinfo.token, &obj_tok_str);
+ h5tools_str_append(buffer,"\"/#%s\"", obj_tok_str);
+ H5free_memory(obj_tok_str);
}
else
h5tools_str_append(buffer, "\"%s\"", obj->objname);
@@ -3110,7 +3110,7 @@ h5tools_print_fill_value(h5tools_str_t *buffer/*in,out*/, const h5tool_format_t
*/
void
h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
- h5tools_context_t *ctx, hid_t dcpl_id, hid_t type_id, hid_t obj_id)
+ h5tools_context_t *ctx, hid_t dcpl_id, hid_t type_id, hid_t dset_id)
{
int nfilters; /* number of filters */
int rank; /* rank */
@@ -3141,7 +3141,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
if (info->line_ncols > 0)
ncols = info->line_ncols;
- storage_size = H5Dget_storage_size(obj_id);
+ storage_size = H5Dget_storage_size(dset_id);
nfilters = H5Pget_nfilters(dcpl_id);
HDstrcpy(f_name,"\0");
@@ -3182,8 +3182,8 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
double ratio = 0;
int ok = 0;
- hid_t tid = H5Dget_type(obj_id);
- hid_t sid = H5Dget_space(obj_id);
+ hid_t tid = H5Dget_type(dset_id);
+ hid_t sid = H5Dget_space(dset_id);
size_t datum_size = H5Tget_size(tid);
int ndims = H5Sget_simple_extent_dims(sid, dims, NULL);
@@ -3241,16 +3241,15 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
break;
case H5D_CONTIGUOUS:
{
- int next;
+ int n_external;
- next = H5Pget_external_count(dcpl_id);
+ n_external = H5Pget_external_count(dcpl_id);
- /*-------------------------------------------------------------------------
- * EXTERNAL_FILE
- *-------------------------------------------------------------------------
- */
ctx->indent_level++;
- if (next) {
+ if (n_external) {
+
+ /* EXTERNAL FILE */
+
ctx->need_prefix = TRUE;
h5tools_str_reset(&buffer);
@@ -3264,7 +3263,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
ctx->indent_level++;
- for (j = 0; j < (unsigned) next; j++) {
+ for (j = 0; j < (unsigned) n_external; j++) {
H5Pget_external(dcpl_id, j, sizeof(name), name, &offset, &size);
ctx->need_prefix = TRUE;
@@ -3284,6 +3283,11 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
}
else {
haddr_t ioffset;
+ void *obj = NULL;
+ hid_t connector_id = H5I_INVALID_HID;
+ hbool_t supported = FALSE;
+
+ /* NORMAL FILE */
ctx->need_prefix = TRUE;
@@ -3297,12 +3301,26 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
h5tools_str_append(&buffer,"SIZE " HSIZE_T_FORMAT, storage_size);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
- ctx->need_prefix = TRUE;
+ /* Only dump the offset if the VOL connector implements
+ * the functionality.
+ */
+ obj = H5VLobject(dset_id);
+ connector_id = H5VLget_connector_id(dset_id);
+ H5VLintrospect_opt_query(obj, connector_id, H5VL_SUBCLS_DATASET, H5VL_NATIVE_DATASET_GET_OFFSET, &supported);
+ H5VLclose(connector_id);
- h5tools_str_reset(&buffer);
- ioffset = H5Dget_offset(obj_id);
- h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
- h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
+ if (supported) {
+
+ ctx->need_prefix = TRUE;
+
+ h5tools_str_reset(&buffer);
+ ioffset = H5Dget_offset(dset_id);
+ if (HADDR_UNDEF == ioffset)
+ h5tools_str_append(&buffer, "OFFSET HADDR_UNDEF");
+ else
+ h5tools_str_append(&buffer, "OFFSET "H5_PRINTF_HADDR_FMT, ioffset);
+ h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
+ }
}
ctx->indent_level--;
}
@@ -3311,23 +3329,23 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
case H5D_VIRTUAL:
{
char dsetname[256]; /* virtual datset name */
- size_t vmaps;
+ size_t n_vmaps;
- H5Pget_virtual_count(dcpl_id, &vmaps);
+ H5Pget_virtual_count(dcpl_id, &n_vmaps);
- if (vmaps) {
- size_t next;
+ if (n_vmaps) {
+ size_t curr_vmap;
ssize_t H5_ATTR_NDEBUG_UNUSED ssize_out;
ctx->indent_level++;
- for (next = 0; next < (unsigned) vmaps; next++) {
- hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, next);
- hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, next);
+ for (curr_vmap = 0; curr_vmap < n_vmaps; curr_vmap++) {
+ hid_t virtual_vspace = H5Pget_virtual_vspace(dcpl_id, curr_vmap);
+ hid_t virtual_srcspace = H5Pget_virtual_srcspace(dcpl_id, curr_vmap);
ctx->need_prefix = TRUE;
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, next, BEGIN);
+ h5tools_str_append(&buffer, "%s %ld %s ", VDS_MAPPING, curr_vmap, BEGIN);
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t) ncols, (hsize_t) 0, (hsize_t) 0);
ctx->indent_level++;
@@ -3358,14 +3376,14 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
ctx->indent_level++;
- ssize_out = H5Pget_virtual_filename(dcpl_id, next, NULL, 0);
+ ssize_out = H5Pget_virtual_filename(dcpl_id, curr_vmap, NULL, 0);
HDassert(ssize_out > 0);
HDassert((size_t)ssize_out < sizeof(name));
- H5Pget_virtual_filename(dcpl_id, next, name, sizeof(name));
- ssize_out = H5Pget_virtual_dsetname(dcpl_id, next, NULL, 0);
+ H5Pget_virtual_filename(dcpl_id, curr_vmap, name, sizeof(name));
+ ssize_out = H5Pget_virtual_dsetname(dcpl_id, curr_vmap, NULL, 0);
HDassert(ssize_out > 0);
HDassert((size_t)ssize_out < sizeof(name));
- H5Pget_virtual_dsetname(dcpl_id, next, dsetname, sizeof(dsetname));
+ H5Pget_virtual_dsetname(dcpl_id, curr_vmap, dsetname, sizeof(dsetname));
ctx->need_prefix = TRUE;
@@ -3629,7 +3647,7 @@ h5tools_dump_dcpl(FILE *stream, const h5tool_format_t *info,
break;
case H5D_FILL_VALUE_USER_DEFINED:
ctx->indent_level--;
- h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, obj_id);
+ h5tools_print_fill_value(&buffer, info, ctx, dcpl_id, type_id, dset_id);
ctx->indent_level++;
break;
case H5D_FILL_VALUE_ERROR:
@@ -3714,6 +3732,17 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_
* instead of the current stripmine position i; this is necessary
* to print the array indices
*/
+ void *obj = NULL;
+ hid_t connector_id = H5I_INVALID_HID;
+ hbool_t supported = FALSE;
+
+ /* Check if comments are supported and return if not */
+ obj = H5VLobject(obj_id);
+ connector_id = H5VLget_connector_id(obj_id);
+ H5VLintrospect_opt_query(obj, connector_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
+ H5VLclose(connector_id);
+ if (!supported)
+ return;
/* setup */
HDmemset(&buffer, 0, sizeof(h5tools_str_t));
@@ -3723,8 +3752,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_
cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
- /* call H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
+ /* call H5Oget_comment again with the correct value */
if (cmt_bufsize > 0) {
comment = (char *)HDmalloc((size_t)(cmt_bufsize+1)); /* new_size including null terminator */
if(comment) {
@@ -3739,7 +3767,7 @@ h5tools_dump_comment(FILE *stream, const h5tool_format_t *info, h5tools_context_
h5tools_render_element(stream, info, ctx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
h5tools_str_close(&buffer);
- } /* end if */
+ }
HDfree(comment);
}
}
@@ -4091,10 +4119,10 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
switch (ref_type) {
case H5R_OBJECT1:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
switch (obj_type) {
case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
datactx.indent_level--;
@@ -4119,7 +4147,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
break;
case H5R_DATASET_REGION1:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
datactx.indent_level--;
@@ -4131,13 +4159,13 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
break;
case H5R_OBJECT2:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
switch (obj_type) {
case H5O_TYPE_GROUP:
break;
case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_data(stream, &outputformat, &datactx, new_obj_id, TRUE);
datactx.indent_level--;
@@ -4168,10 +4196,10 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
ncols = outputformat.line_ncols;
/* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
else {
- if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
@@ -4223,7 +4251,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
break;
case H5R_ATTR:
H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
h5tools_dump_region_attribute(new_obj_id, stream, &outputformat, &datactx,
&buffer, &curr_pos, ncols, i, elmt_counter);
if(H5Aclose(new_obj_id) < 0)
diff --git a/tools/lib/h5tools_error.h b/tools/lib/h5tools_error.h
index 4e2e935..764fb91 100644
--- a/tools/lib/h5tools_error.h
+++ b/tools/lib/h5tools_error.h
@@ -101,14 +101,16 @@ do {
* H5TOOLS_PUSH_ERROR macro, used to push an error to an error stack. Not meant to
* be called directly.
*/
-#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \
-do { \
- if (estack_id >= 0 && err_cls >= 0) \
- H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \
- else { \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- } \
+#define H5TOOLS_PUSH_ERROR(estack_id, err_cls, maj_err_id, min_err_id, ...) \
+do { \
+ if (enable_error_stack > 0) { \
+ if (estack_id >= 0 && err_cls >= 0) \
+ H5Epush2(estack_id, __FILE__, FUNC, __LINE__, err_cls, maj_err_id, min_err_id, __VA_ARGS__); \
+ else { \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ } \
+ } \
} while(0)
/*
@@ -167,30 +169,30 @@ do {
#ifdef H5_TOOLS_DEBUG
-#define H5TOOLS_START_DEBUG(...) \
-do { \
- H5tools_INDENT_g += 2; \
+#define H5TOOLS_START_DEBUG(...) \
+do { \
+ H5tools_INDENT_g += 2; \
HDfprintf(stderr, "%*sENTER %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- HDfflush(stderr); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ HDfflush(stderr); \
} while(0)
-#define H5TOOLS_DEBUG(...) \
-do { \
+#define H5TOOLS_DEBUG(...) \
+do { \
HDfprintf(stderr, "%*s %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- HDfflush(stderr); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ HDfflush(stderr); \
} while(0)
-#define H5TOOLS_ENDDEBUG(...) \
-do { \
+#define H5TOOLS_ENDDEBUG(...) \
+do { \
HDfprintf(stderr, "%*sEXIT %s:%d in %s()...", H5tools_INDENT_g, "", __FILE__, __LINE__, FUNC); \
- HDfprintf(stderr, __VA_ARGS__); \
- HDfprintf(stderr, "\n"); \
- H5tools_INDENT_g -= 2; \
- HDfflush(stderr); \
+ HDfprintf(stderr, __VA_ARGS__); \
+ HDfprintf(stderr, "\n"); \
+ H5tools_INDENT_g -= 2; \
+ HDfflush(stderr); \
} while(0)
#else
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 6515ecd..5c777a9 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -1101,12 +1101,12 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
{
/* Object references -- show the type and OID of the referenced object. */
H5O_info2_t oi;
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
H5Oget_info3(obj, &oi, H5O_INFO_BASIC);
- H5Otoken_to_str(obj, &oi.token, &obj_addr_str);
+ H5Otoken_to_str(obj, &oi.token, &obj_tok_str);
}
else
H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed");
@@ -1137,13 +1137,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
/* Print OID */
if(info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, obj_addr_str);
+ h5tools_str_append(str, info->obj_format, obj_tok_str);
else
- h5tools_str_append(str, info->obj_format, oi.fileno, obj_addr_str);
+ h5tools_str_append(str, info->obj_format, oi.fileno, obj_tok_str);
- if(obj_addr_str) {
- H5free_memory(obj_addr_str);
- obj_addr_str = NULL;
+ if(obj_tok_str) {
+ H5free_memory(obj_tok_str);
+ obj_tok_str = NULL;
}
if(obj >= 0)
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 45e436c..1a1c2db 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -648,17 +648,17 @@ static void
dump_table(hid_t fid, char* tablename, table_t *table)
{
unsigned u;
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
PRINTSTREAM(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
for (u = 0; u < table->nobjs; u++) {
- H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_addr_str);
+ H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_tok_str);
- PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_addr_str,
+ PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_tok_str,
table->objs[u].objname,
table->objs[u].displayed, table->objs[u].recorded);
- H5VLfree_token_str(fid, obj_addr_str);
+ H5VLfree_token_str(fid, obj_tok_str);
}
}
@@ -1079,6 +1079,55 @@ done:
return ret_value;
}
+#ifdef H5_HAVE_ROS3_VFD
+/*----------------------------------------------------------------------------
+ *
+ * Function: h5tools_parse_ros3_fapl_tuple
+ *
+ * Purpose: A convenience function that parses a string containing a tuple
+ * of S3 VFD credential information and then passes the result to
+ * `h5tools_populate_ros3_fapl()` in order to setup a valid
+ * configuration for the S3 VFD.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *----------------------------------------------------------------------------
+ */
+herr_t
+h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_ros3_fapl_t *fapl_config_out)
+{
+ const char *ccred[3];
+ unsigned nelems = 0;
+ char *start = NULL;
+ char *s3cred_src = NULL;
+ char **s3cred = NULL;
+ herr_t ret_value = SUCCEED;
+
+ /* Attempt to parse S3 credentials tuple */
+ if (parse_tuple(tuple_str, delim, &s3cred_src, &nelems, &s3cred) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to parse S3 VFD info tuple");
+
+ /* Sanity-check tuple count */
+ if (nelems != 3)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid S3 VFD credentials");
+
+ ccred[0] = (const char *)s3cred[0];
+ ccred[1] = (const char *)s3cred[1];
+ ccred[2] = (const char *)s3cred[2];
+
+ if (0 == h5tools_populate_ros3_fapl(fapl_config_out, ccred))
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to populate S3 VFD FAPL config");
+
+done:
+ if (s3cred)
+ HDfree(s3cred);
+ if (s3cred_src)
+ HDfree(s3cred_src);
+
+ return ret_value;
+}
+
/*----------------------------------------------------------------------------
*
@@ -1142,7 +1191,6 @@ done:
*
*----------------------------------------------------------------------------
*/
-#ifdef H5_HAVE_ROS3_VFD
int
h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa,
const char **values)
@@ -1266,73 +1314,72 @@ h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa,
done:
return ret_value;
-
} /* h5tools_populate_ros3_fapl */
#endif /* H5_HAVE_ROS3_VFD */
-
-/*-----------------------------------------------------------------------------
- *
- * Function: h5tools_set_configured_fapl
- *
- * Purpose: prepare fapl_id with the given property list, according to
- * VFD prototype.
+#ifdef H5_HAVE_LIBHDFS
+/*----------------------------------------------------------------------------
*
- * Return: 0 on failure, 1 on success
+ * Function: h5tools_parse_hdfs_fapl_tuple
*
- * Programmer: Jacob Smith
- * 2018-05-21
+ * Purpose: A convenience function that parses a string containing a tuple
+ * of HDFS VFD configuration information.
*
- * Changes: None.
+ * Return: SUCCEED/FAIL
*
- *-----------------------------------------------------------------------------
+ *----------------------------------------------------------------------------
*/
-int
-h5tools_set_configured_fapl(hid_t fapl_id,
- const char vfd_name[],
- void *fapl_t_ptr)
+herr_t
+h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_hdfs_fapl_t *fapl_config_out)
{
- int ret_value = 1;
-
- if (fapl_id < 0) {
- return 0;
+ unsigned long k = 0;
+ unsigned nelems = 0;
+ char *props_src = NULL;
+ char **props = NULL;
+ herr_t ret_value = SUCCEED;
+
+ /* Attempt to parse HDFS configuration tuple */
+ if (parse_tuple(tuple_str, delim, &props_src, &nelems, &props) < 0)
+ H5TOOLS_GOTO_ERROR(FAIL, "failed to parse HDFS VFD configuration tuple");
+
+ /* Sanity-check tuple count */
+ if (nelems != 5)
+ H5TOOLS_GOTO_ERROR(FAIL, "invalid HDFS VFD configuration");
+
+ /* Populate fapl configuration structure with given properties.
+ * WARNING: No error-checking is done on length of input strings...
+ * Silent overflow is possible, albeit unlikely.
+ */
+ if (HDstrncmp(props[0], "", 1)) {
+ HDstrncpy(fapl_config_out->namenode_name, (const char *)props[0], HDstrlen(props[0]));
}
-
- if (!strcmp("", vfd_name)) {
- goto done;
-
-#ifdef H5_HAVE_ROS3_VFD
- } else if (!strcmp("ros3", vfd_name)) {
- if ((fapl_id == H5P_DEFAULT) ||
- (fapl_t_ptr == NULL) ||
- (FAIL == H5Pset_fapl_ros3(
- fapl_id,
- (H5FD_ros3_fapl_t *)fapl_t_ptr)))
- {
- ret_value = 0;
- goto done;
- }
-#endif /* H5_HAVE_ROS3_VFD */
-
-#ifdef H5_HAVE_LIBHDFS
- } else if (!strcmp("hdfs", vfd_name)) {
- if ((fapl_id == H5P_DEFAULT) ||
- (fapl_t_ptr == NULL) ||
- (FAIL == H5Pset_fapl_hdfs(
- fapl_id,
- (H5FD_hdfs_fapl_t *)fapl_t_ptr)))
- {
- ret_value = 0;
- goto done;
- }
-#endif /* H5_HAVE_LIBHDFS */
-
- } else {
- ret_value = 0; /* unrecognized fapl type "name" */
+ if (HDstrncmp(props[1], "", 1)) {
+ k = strtoul((const char *)props[1], NULL, 0);
+ if (errno == ERANGE)
+ H5TOOLS_GOTO_ERROR(FAIL, "supposed port number wasn't");
+ fapl_config_out->namenode_port = (int32_t)k;
+ }
+ if (HDstrncmp(props[2], "", 1)) {
+ HDstrncpy(fapl_config_out->kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
+ }
+ if (HDstrncmp(props[3], "", 1)) {
+ HDstrncpy(fapl_config_out->user_name, (const char *)props[3], HDstrlen(props[3]));
+ }
+ if (HDstrncmp(props[4], "", 1)) {
+ k = HDstrtoul((const char *)props[4], NULL, 0);
+ if (errno == ERANGE)
+ H5TOOLS_GOTO_ERROR(FAIL, "supposed buffersize number wasn't");
+ fapl_config_out->stream_buffer_size = (int32_t)k;
}
done:
- return ret_value;
+ if (props)
+ HDfree(props);
+ if (props_src)
+ HDfree(props_src);
-} /* h5tools_set_configured_fapl() */
+ return ret_value;
+}
+#endif /* H5_HAVE_LIBHDFS */
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 598930c..42144cc 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -173,10 +173,15 @@ H5TOOLS_DLL void h5tools_setprogname(const char*progname);
H5TOOLS_DLL int h5tools_getstatus(void);
H5TOOLS_DLL void h5tools_setstatus(int d_status);
H5TOOLS_DLL int h5tools_getenv_update_hyperslab_bufsize(void);
-H5TOOLS_DLL int h5tools_set_configured_fapl(hid_t fapl_id, const char vfd_name[], void *fapl_t_ptr);
#ifdef H5_HAVE_ROS3_VFD
+H5TOOLS_DLL herr_t h5tools_parse_ros3_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_ros3_fapl_t *fapl_config_out);
H5TOOLS_DLL int h5tools_populate_ros3_fapl(H5FD_ros3_fapl_t *fa, const char **values);
#endif /* H5_HAVE_ROS3_VFD */
+#ifdef H5_HAVE_LIBHDFS
+H5TOOLS_DLL herr_t h5tools_parse_hdfs_fapl_tuple(const char *tuple_str, int delim,
+ H5FD_hdfs_fapl_t *fapl_config_out);
+#endif
#ifdef __cplusplus
}
diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c
index 726f4c4..2f9958b 100644
--- a/tools/libtest/h5tools_test_utils.c
+++ b/tools/libtest/h5tools_test_utils.c
@@ -960,7 +960,7 @@ error :
*
* Function: test_set_configured_fapl()
*
- * Purpose: Verify `h5tools_set_configured_fapl()` with ROS3 VFD
+ * Purpose: Verify `h5tools_get_fapl()` with ROS3 and HDFS VFDs
*
* Return: 0 if test passes
* 1 if failure
@@ -1147,7 +1147,8 @@ test_set_configured_fapl(void)
TESTING("programmatic fapl set");
for (i = 0; i < n_cases; i++) {
- int result;
+ h5tools_fapl_info_t fapl_info;
+ hid_t result;
testcase C = cases[i];
fapl_id = H5I_INVALID_HID;
@@ -1169,11 +1170,14 @@ test_set_configured_fapl(void)
#endif /* UTIL_TEST_DEBUG */
/* test */
- result = h5tools_set_configured_fapl(
- fapl_id,
- C.vfdname,
- C.conf_fa);
- JSVERIFY( result, C.expected, C.message )
+ fapl_info.type = VFD_BY_NAME;
+ fapl_info.info = C.conf_fa;
+ fapl_info.u.name = C.vfdname;
+ result = h5tools_get_fapl(H5P_DEFAULT, &fapl_info);
+ if (C.expected == 0)
+ JSVERIFY( result, H5I_INVALID_HID, C.message)
+ else
+ JSVERIFY_NOT( result, H5I_INVALID_HID, C.message)
#if UTIL_TEST_DEBUG
HDfprintf(stderr, "after test\n"); fflush(stderr);
diff --git a/tools/src/h5copy/CMakeLists.txt b/tools/src/h5copy/CMakeLists.txt
index 29888f2..8f230a0 100644
--- a/tools/src/h5copy/CMakeLists.txt
+++ b/tools/src/h5copy/CMakeLists.txt
@@ -7,6 +7,7 @@ project (HDF5_TOOLS_SRC_H5COPY C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5copy ${HDF5_TOOLS_SRC_H5COPY_SOURCE_DIR}/h5copy.c)
target_include_directories (h5copy PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5copy PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5copy STATIC)
target_link_libraries (h5copy PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5copy PROPERTIES FOLDER tools)
@@ -18,6 +19,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5copy-shared ${HDF5_TOOLS_SRC_H5COPY_SOURCE_DIR}/h5copy.c)
target_include_directories (h5copy-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5copy-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5copy-shared SHARED)
target_link_libraries (h5copy-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5copy-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5copy/h5copy.c b/tools/src/h5copy/h5copy.c
index e1370e2..8805d08 100644
--- a/tools/src/h5copy/h5copy.c
+++ b/tools/src/h5copy/h5copy.c
@@ -342,13 +342,13 @@ main (int argc, const char *argv[])
/* Attempt to open an existing HDF5 file first. Need to open the dst file
before the src file just in case that the dst and src are the same file
*/
- fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0);
+ fid_dst = h5tools_fopen(fname_dst, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0);
/*-------------------------------------------------------------------------
* open input file
*-------------------------------------------------------------------------*/
- fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0);
+ fid_src = h5tools_fopen(fname_src, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, 0);
/*-------------------------------------------------------------------------
* test for error in opening input file
diff --git a/tools/src/h5diff/CMakeLists.txt b/tools/src/h5diff/CMakeLists.txt
index 93e99cf..eec7246 100644
--- a/tools/src/h5diff/CMakeLists.txt
+++ b/tools/src/h5diff/CMakeLists.txt
@@ -10,6 +10,7 @@ if (NOT ONLY_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_main.c
)
target_include_directories (h5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}")
#target_compile_definitions (h5diff PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5diff STATIC)
target_link_libraries (h5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
@@ -24,6 +25,7 @@ if (BUILD_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/h5diff_main.c
)
target_include_directories (h5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
#target_compile_definitions (h5diff-shared PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5diff-shared SHARED)
target_link_libraries (h5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
diff --git a/tools/src/h5dump/CMakeLists.txt b/tools/src/h5dump/CMakeLists.txt
index dbf92cf..0b6c968 100644
--- a/tools/src/h5dump/CMakeLists.txt
+++ b/tools/src/h5dump/CMakeLists.txt
@@ -11,6 +11,7 @@ if (NOT ONLY_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.c
)
target_include_directories (h5dump PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5dump PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5dump STATIC)
target_link_libraries (h5dump PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5dump PROPERTIES FOLDER tools)
@@ -26,6 +27,7 @@ if (BUILD_SHARED_LIBS)
${HDF5_TOOLS_SRC_H5DUMP_SOURCE_DIR}/h5dump_xml.c
)
target_include_directories (h5dump-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5dump-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5dump-shared SHARED)
target_link_libraries (h5dump-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5dump-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c
index d97fdc0..e49141d 100644
--- a/tools/src/h5dump/h5dump.c
+++ b/tools/src/h5dump/h5dump.c
@@ -25,23 +25,25 @@ static int useschema = 1;
static const char *xml_dtd_uri = NULL;
#ifdef H5_HAVE_ROS3_VFD
+/* Default "anonymous" S3 configuration */
static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
+/* "Default" HDFS configuration */
static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -1251,106 +1253,37 @@ end_collect:
goto done;
case '$':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
+ usage(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- /* s3 credential */
- {
- char **s3_cred = NULL;
- char *s3_cred_string = NULL;
- const char *ccred[3];
- unsigned nelems = 0;
- if (FAIL == parse_tuple(opt_arg, ',', &s3_cred_string, &nelems, &s3_cred)) {
- error_msg("unable to parse malformed s3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- if (nelems != 3) {
- error_msg("s3 credentials expects 3 elements\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- ccred[0] = (const char *)s3_cred[0];
- ccred[1] = (const char *)s3_cred[1];
- ccred[2] = (const char *)s3_cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Invalid S3 credentials\n");
- usage(h5tools_getprogname());
- free_handler(hand, argc);
- hand = NULL;
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- HDfree(s3_cred);
- HDfree(s3_cred_string);
- } /* s3 credential block */
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case '#':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
-#else
- {
- /* read hdfs properties tuple and store values in `hdfs_fa` */
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * WARNING: No error-checking is done on length of input
- * strings... Silent overflow is possible, albeit
- * unlikely.
- */
- if (strncmp(props[0], "", 1))
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
-
- if (strncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (strncmp(props[2], "", 1))
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
-
- if (strncmp(props[3], "", 1))
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
-
- if (strncmp(props[4], "", 1)) {
- k = strtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- h5tools_setstatus(EXIT_FAILURE);
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
+ usage(h5tools_getprogname());
+ free_handler(hand, argc);
+ hand = NULL;
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
-#endif /* H5_HAVE_LIBHDFS */
+#else
+ error_msg("HDFS VFD not enabled.\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+#endif
break;
case '?':
@@ -1482,53 +1415,44 @@ main(int argc, const char *argv[])
h5trav_set_index(sort_by, sort_order);
if (driver != NULL) {
- void *conf_fa = NULL;
+ h5tools_fapl_info_t fapl_info;
+
+ /* Currently, only retrieval of VFDs is supported. */
+ fapl_info.type = VFD_BY_NAME;
+ fapl_info.info = NULL;
+ fapl_info.u.name = driver;
- if (!strcmp(driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
+ if (!HDstrcmp(driver, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ fapl_info.info = (void *)&ros3_fa;
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+#endif
}
- else if (!HDstrcmp(driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
+ else if (!HDstrcmp(driver, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ fapl_info.info = (void *)&hdfs_fa;
+#else
+ error_msg("The HDFS VFD is not enabled.\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
-#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+#endif
}
- if (conf_fa != NULL) {
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("unable to create fapl entry\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
- /* driver guaranteed "ros3" or "hdfs" */
- /* conf_fa appropriate to driver */
- if (0 == h5tools_set_configured_fapl(fapl_id, driver, conf_fa)) {
- error_msg("unable to set fapl\n");
- h5tools_setstatus(EXIT_FAILURE);
- goto done;
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) {
+ error_msg("unable to create FAPL for file access\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
}
} /* driver defined */
while(opt_ind < argc) {
fname = HDstrdup(argv[opt_ind++]);
- if (fapl_id != H5P_DEFAULT) {
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, driver, NULL, 0);
- }
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0);
if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
@@ -1704,6 +1628,7 @@ main(int argc, const char *argv[])
/* To Do: clean up XML table */
H5Eset_auto2(H5E_DEFAULT, func, edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
leave(h5tools_getstatus());
@@ -1735,6 +1660,7 @@ done:
/* To Do: clean up XML table */
H5Eset_auto2(H5E_DEFAULT, func, edata);
+ H5Eset_auto2(H5tools_ERR_STACK_g, tools_func, tools_edata);
leave(h5tools_getstatus());
} /* main */
diff --git a/tools/src/h5dump/h5dump_ddl.c b/tools/src/h5dump/h5dump_ddl.c
index a410fda..e97ab7e 100644
--- a/tools/src/h5dump/h5dump_ddl.c
+++ b/tools/src/h5dump/h5dump_ddl.c
@@ -816,14 +816,14 @@ dump_group(hid_t gid, const char *name)
/* dump unamed type in root group */
for(u = 0; u < type_table->nobjs; u++)
if(!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
@@ -1136,6 +1136,22 @@ dump_fcpl(hid_t fid)
unsigned sym_ik; /* symbol table B-tree internal 'K' value */
unsigned istore_ik; /* indexed storage B-tree internal 'K' value */
+ void *obj = NULL;
+ hid_t connector_id = H5I_INVALID_HID;
+ hbool_t supported = FALSE;
+
+ /* Dumping the information here only makes sense for the native
+ * VOL connector. The only VOL call here is H5Fget_info(), so we'll
+ * use that as a proxy for "native-ness". If that isn't supported, we'll
+ * just return.
+ */
+ obj = H5VLobject(fid);
+ connector_id = H5VLget_connector_id(fid);
+ H5VLintrospect_opt_query(obj, connector_id, H5VL_SUBCLS_FILE, H5VL_NATIVE_FILE_GET_INFO, &supported);
+ H5VLclose(connector_id);
+ if (!supported)
+ return;
+
fcpl=H5Fget_create_plist(fid);
H5Fget_info2(fid, &finfo);
H5Pget_userblock(fcpl,&userblock);
@@ -1258,11 +1274,11 @@ dump_fcontents(hid_t fid)
for (u = 0; u < type_table->nobjs; u++) {
if (!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
- H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_addr_str);
- PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(fid, &type_table->objs[u].obj_token, &obj_tok_str);
+ PRINTSTREAM(rawoutstream, " %-10s /#%s\n", "datatype", obj_tok_str);
+ H5free_memory(obj_tok_str);
}
}
}
@@ -1914,12 +1930,12 @@ handle_datatypes(hid_t fid, const char *type, void H5_ATTR_UNUSED * data, int pe
char name[128];
if(!type_table->objs[idx].recorded) {
- char *obj_addr_string = NULL;
+ char *obj_tok_str = NULL;
/* unamed datatype */
- H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_addr_string);
- HDsprintf(name, "/#%s", obj_addr_string);
- H5free_memory(obj_addr_string);
+ H5Otoken_to_str(fid, &type_table->objs[idx].obj_token, &obj_tok_str);
+ HDsprintf(name, "/#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
if(!HDstrcmp(name, real_name))
break;
diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c
index d9f1f67..4f58b73 100644
--- a/tools/src/h5dump/h5dump_xml.c
+++ b/tools/src/h5dump/h5dump_xml.c
@@ -578,7 +578,7 @@ int
xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen)
{
H5O_token_t obj_token;
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
int lookup_ret;
if (outlen < 22) return 1;
@@ -591,9 +591,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
if (gen) {
ref_path_table_gen_fake(str, &obj_token);
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -606,9 +606,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
if (gen) {
ref_path_table_gen_fake(str, &obj_token);
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -618,9 +618,9 @@ xml_name_to_XID(hid_t loc_id, const char *str, char *outstr, int outlen, int gen
}
}
- H5Otoken_to_str(loc_id, &obj_token, &obj_addr_str);
- HDsprintf(outstr, "xid_%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(loc_id, &obj_token, &obj_tok_str);
+ HDsprintf(outstr, "xid_%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
return 0;
}
@@ -2659,14 +2659,14 @@ xml_dump_group(hid_t gid, const char *name)
/* Very special case: dump unamed type in root group */
for(u = 0; u < type_table->nobjs; u++) {
if(!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
@@ -2747,14 +2747,14 @@ xml_dump_group(hid_t gid, const char *name)
/* Very special case: dump unamed type in root group */
for(u = 0; u < type_table->nobjs; u++) {
if(!type_table->objs[u].recorded) {
- char *obj_addr_str = NULL;
+ char *obj_tok_str = NULL;
dset = H5Dopen2(gid, type_table->objs[u].objname, H5P_DEFAULT);
type = H5Dget_type(dset);
- H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_addr_str);
- HDsprintf(type_name, "#%s", obj_addr_str);
- H5free_memory(obj_addr_str);
+ H5Otoken_to_str(dset, &type_table->objs[u].obj_token, &obj_tok_str);
+ HDsprintf(type_name, "#%s", obj_tok_str);
+ H5free_memory(obj_tok_str);
dump_function_table->dump_named_datatype_function(type, type_name);
H5Tclose(type);
diff --git a/tools/src/h5format_convert/CMakeLists.txt b/tools/src/h5format_convert/CMakeLists.txt
index 70c07ee..863ecbe 100644
--- a/tools/src/h5format_convert/CMakeLists.txt
+++ b/tools/src/h5format_convert/CMakeLists.txt
@@ -7,6 +7,7 @@ project (HDF5_TOOLS_SRC_H5FC C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5format_convert ${HDF5_TOOLS_SRC_H5FC_SOURCE_DIR}/h5format_convert.c)
target_include_directories (h5format_convert PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5format_convert PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5format_convert STATIC)
target_link_libraries (h5format_convert PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5format_convert PROPERTIES FOLDER tools)
@@ -17,6 +18,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5format_convert-shared ${HDF5_TOOLS_SRC_H5FC_SOURCE_DIR}/h5format_convert.c)
target_include_directories (h5format_convert-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5format_convert-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5format_convert-shared SHARED)
target_link_libraries (h5format_convert-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5format_convert-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c
index bb606ac..ae72ea9 100644
--- a/tools/src/h5format_convert/h5format_convert.c
+++ b/tools/src/h5format_convert/h5format_convert.c
@@ -42,13 +42,13 @@ static int verbose_g = 0;
static const char *s_opts = "hVvd:n";
static struct long_options l_opts[] = {
{ "help", no_arg, 'h' },
- { "hel", no_arg, 'h'},
- { "he", no_arg, 'h'},
+ { "hel", no_arg, 'h'},
+ { "he", no_arg, 'h'},
{ "version", no_arg, 'V' },
- { "version", no_arg, 'V' },
- { "versio", no_arg, 'V' },
- { "versi", no_arg, 'V' },
- { "vers", no_arg, 'V' },
+ { "version", no_arg, 'V' },
+ { "versio", no_arg, 'V' },
+ { "versi", no_arg, 'V' },
+ { "vers", no_arg, 'V' },
{ "verbose", no_arg, 'v' },
{ "verbos", no_arg, 'v' },
{ "verbo", no_arg, 'v' },
@@ -60,6 +60,7 @@ static struct long_options l_opts[] = {
{ "noop", no_arg, 'n' },
{ "noo", no_arg, 'n' },
{ "no", no_arg, 'n' },
+ { "enable-error-stack", no_arg, 'E' },
{ NULL, 0, '\0' }
};
@@ -120,55 +121,59 @@ parse_command_line(int argc, const char **argv)
/* no arguments */
if (argc == 1) {
usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
goto error;
}
/* parse command line options */
while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) {
- switch((char) opt) {
- case 'h':
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'V':
- print_version(h5tools_getprogname());
- h5tools_setstatus(EXIT_SUCCESS);
- goto error;
-
- case 'v':
- verbose_g = TRUE;
- break;
-
- case 'd': /* -d dname */
- if(opt_arg != NULL && *opt_arg)
- dname_g = HDstrdup(opt_arg);
- if(dname_g == NULL) {
- h5tools_setstatus(EXIT_FAILURE);
- error_msg("No dataset name\n", opt_arg);
- usage(h5tools_getprogname());
- goto error;
- }
- dset_g = TRUE;
- break;
-
- case 'n': /* -n */
- noop_g = TRUE;
- break;
-
- default:
- h5tools_setstatus(EXIT_FAILURE);
- usage(h5tools_getprogname());
- goto error;
- break;
- } /* switch */
+ switch((char) opt) {
+ case 'h':
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'V':
+ print_version(h5tools_getprogname());
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto error;
+
+ case 'v':
+ verbose_g = TRUE;
+ break;
+
+ case 'd': /* -d dname */
+ if(opt_arg != NULL && *opt_arg)
+ dname_g = HDstrdup(opt_arg);
+ if(dname_g == NULL) {
+ h5tools_setstatus(EXIT_FAILURE);
+ error_msg("No dataset name\n", opt_arg);
+ usage(h5tools_getprogname());
+ goto error;
+ }
+ dset_g = TRUE;
+ break;
+
+ case 'n': /* -n */
+ noop_g = TRUE;
+ break;
+
+ case 'E':
+ enable_error_stack = 1;
+ break;
+
+ default:
+ h5tools_setstatus(EXIT_FAILURE);
+ usage(h5tools_getprogname());
+ goto error;
+ break;
+ } /* switch */
} /* while */
if (argc <= opt_ind) {
error_msg("missing file name\n");
usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
+ h5tools_setstatus(EXIT_FAILURE);
goto error;
}
@@ -421,7 +426,7 @@ main(int argc, const char *argv[])
HDfprintf(stdout, "It is noop...\n");
/* Open the HDF5 file */
- if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, NULL, NULL, 0)) < 0) {
+ if((fid = h5tools_fopen(fname_g, H5F_ACC_RDWR, H5P_DEFAULT, FALSE, NULL, 0)) < 0) {
error_msg("unable to open file \"%s\"\n", fname_g);
h5tools_setstatus(EXIT_FAILURE);
goto done;
diff --git a/tools/src/h5ls/CMakeLists.txt b/tools/src/h5ls/CMakeLists.txt
index 7be33b5..c1ce006 100644
--- a/tools/src/h5ls/CMakeLists.txt
+++ b/tools/src/h5ls/CMakeLists.txt
@@ -7,6 +7,7 @@ project (HDF5_TOOLS_SRC_H5LS C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5ls ${HDF5_TOOLS_SRC_H5LS_SOURCE_DIR}/h5ls.c)
target_include_directories (h5ls PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5ls PRIVATE "${HDF5_CMAKE_C_FLAGS}")
#target_compile_definitions(h5ls PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5ls STATIC)
target_link_libraries (h5ls PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
@@ -19,6 +20,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5ls-shared ${HDF5_TOOLS_SRC_H5LS_SOURCE_DIR}/h5ls.c)
target_include_directories (h5ls-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5ls-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
#target_compile_definitions(h5ls-shared PRIVATE H5_TOOLS_DEBUG)
TARGET_C_PROPERTIES (h5ls-shared SHARED)
target_link_libraries (h5ls-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c
index f3f9ede..f82827c 100644
--- a/tools/src/h5ls/h5ls.c
+++ b/tools/src/h5ls/h5ls.c
@@ -1333,10 +1333,10 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
switch (ref_type) {
case H5R_OBJECT1:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
switch (obj_type) {
case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_dset(stream, info, &datactx, new_obj_id);
datactx.indent_level--;
@@ -1363,7 +1363,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
break;
case H5R_DATASET_REGION1:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_dset(stream, info, &datactx, new_obj_id);
datactx.indent_level--;
@@ -1377,13 +1377,13 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
break;
case H5R_OBJECT2:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
- if (H5Rget_obj_type3((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
+ if (H5Rget_obj_type3(&ref_buf[i], H5P_DEFAULT, &obj_type) >= 0) {
switch (obj_type) {
case H5O_TYPE_GROUP:
break;
case H5O_TYPE_DATASET:
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
datactx.indent_level++;
h5tools_dump_dset(stream, info, &datactx, new_obj_id);
datactx.indent_level--;
@@ -1416,10 +1416,10 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
ncols = info->line_ncols;
/* if (new_obj_id < 0) - could mean that no reference was written do not throw failure */
- if((new_obj_id = H5Ropen_object((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ if((new_obj_id = H5Ropen_object(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) < 0)
H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
else {
- if((new_obj_sid = H5Ropen_region((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_sid = H5Ropen_region(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
if (h5tools_is_zero(&ref_buf[i], H5Tget_size(H5T_STD_REF))) {
H5TOOLS_DEBUG("NULL H5R_DATASET_REGION2");
@@ -1471,7 +1471,7 @@ dump_reference(FILE *stream, const h5tool_format_t *info, h5tools_context_t *ctx
break;
case H5R_ATTR:
H5TOOLS_DEBUG("ref_type is H5R_ATTR");
- if((new_obj_id = H5Ropen_attr((const H5R_ref_t *)&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
+ if((new_obj_id = H5Ropen_attr(&ref_buf[i], H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
h5tools_dump_region_attribute(new_obj_id, stream, info, &datactx, &buffer, &curr_pos, (size_t)ncols, (hsize_t)0, (hsize_t)0);
if(H5Aclose(new_obj_id) < 0)
H5TOOLS_INFO("H5Aclose H5R_ATTR failed");
@@ -2334,13 +2334,13 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
} /* end if */
else {
- hid_t obj = H5I_INVALID_HID; /* ID of object opened */
+ hid_t obj_id = H5I_INVALID_HID; /* ID of object opened */
/* Open the object. Not all objects can be opened. If this is the case
* then return right away.
*/
H5TOOLS_DEBUG("Open object name=%s", name);
- if (obj_type >= 0 && (obj = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
+ if (obj_type >= 0 && (obj_id = H5Oopen(iter->fid, name, H5P_DEFAULT)) < 0) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, " *ERROR*\n");
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
@@ -2350,7 +2350,7 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
/* List the first line of information for the object. */
H5TOOLS_DEBUG("Object type:%d", obj_type);
if (obj_type >= 0 && dispatch_g[obj_type].list1)
- (dispatch_g[obj_type].list1)(obj);
+ (dispatch_g[obj_type].list1)(obj_id);
if (!iter->symlink_target || (verbose_g > 0)) {
h5tools_str_reset(&buffer);
h5tools_str_append(&buffer, "\n");
@@ -2362,23 +2362,26 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
if (verbose_g > 0) {
size_t buf_size = 0;
char* comment = NULL;
- char* obj_addr_str = NULL;
+ char* obj_tok_str = NULL;
ssize_t cmt_bufsize = -1;
+ void *obj = NULL;
+ hid_t connector_id = H5I_INVALID_HID;
+ hbool_t supported = FALSE;
/* Display attributes */
H5TOOLS_DEBUG("Display attributes");
if (obj_type >= 0)
- H5Aiterate2(obj, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
+ H5Aiterate2(obj_id, H5_INDEX_NAME, H5_ITER_INC, NULL, list_attr, NULL);
/* Object location & reference count */
- H5Otoken_to_str(obj, &oinfo->token, &obj_addr_str);
+ H5Otoken_to_str(obj_id, &oinfo->token, &obj_tok_str);
h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_addr_str);
+ h5tools_str_append(&buffer, " %-10s %lu:%s\n", "Location:", oinfo->fileno, obj_tok_str);
h5tools_str_append(&buffer, " %-10s %u\n", "Links:", (unsigned)oinfo->rc);
h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- H5free_memory(obj_addr_str);
+ H5free_memory(obj_tok_str);
/* Modification time */
if (oinfo->mtime > 0) {
@@ -2397,36 +2400,45 @@ list_obj(const char *name, const H5O_info2_t *oinfo, const char *first_seen, voi
} /* end if */
} /* end if */
- /* Object comment */
- cmt_bufsize = H5Oget_comment(obj, comment, buf_size);
-
- /* if the actual length of the comment is longer than cmt_bufsize, then call
- * H5Oget_comment again with the correct value.
- * If the call to H5Oget_comment returned an error, skip this block */
- if (cmt_bufsize > 0) {
- comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
- if (comment) {
- cmt_bufsize = H5Oget_comment(obj, comment, (size_t)cmt_bufsize);
- if (cmt_bufsize > 0) {
- comment[cmt_bufsize] = 0;
- h5tools_str_reset(&buffer);
- h5tools_str_append(&buffer, " %-10s \"", "Comment:");
- print_string(&buffer, comment, FALSE);
- h5tools_str_append(&buffer, "\"\n");
- h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
- } /* end if */
- HDfree(comment);
+ /* Only emit comments if the VOL connector supports that */
+ obj = H5VLobject(obj_id);
+ connector_id = H5VLget_connector_id(obj_id);
+ H5VLintrospect_opt_query(obj, connector_id, H5VL_SUBCLS_OBJECT, H5VL_NATIVE_OBJECT_GET_COMMENT, &supported);
+ H5VLclose(connector_id);
+
+ if (supported) {
+
+ /* Object comment */
+ cmt_bufsize = H5Oget_comment(obj_id, comment, buf_size);
+
+ /* if the actual length of the comment is longer than cmt_bufsize, then call
+ * H5Oget_comment again with the correct value.
+ */
+ if (cmt_bufsize > 0) {
+ comment = (char *)HDmalloc((size_t)cmt_bufsize + 1); /* new_size including null terminator */
+ if (comment) {
+ cmt_bufsize = H5Oget_comment(obj_id, comment, (size_t)cmt_bufsize);
+ if (cmt_bufsize > 0) {
+ comment[cmt_bufsize] = 0;
+ h5tools_str_reset(&buffer);
+ h5tools_str_append(&buffer, " %-10s \"", "Comment:");
+ print_string(&buffer, comment, FALSE);
+ h5tools_str_append(&buffer, "\"\n");
+ h5tools_render_element(rawoutstream, info, &ctx, &buffer, &curr_pos, (size_t)info->line_ncols, (hsize_t)0, (hsize_t)0);
+ } /* end if */
+ HDfree(comment);
+ }
}
}
} /* end if */
/* Detailed list for object */
if (obj_type >= 0 && dispatch_g[obj_type].list2)
- (dispatch_g[obj_type].list2)(obj, name);
+ (dispatch_g[obj_type].list2)(obj_id, name);
/* Close the object. */
if (obj_type >= 0)
- H5Oclose(obj);
+ H5Oclose(obj_id);
} /* end else */
done:
@@ -2833,41 +2845,41 @@ leave(int ret)
int
main(int argc, const char *argv[])
{
- hid_t file_id = H5I_INVALID_HID;
- char *fname = NULL, *oname = NULL, *x;
- const char *s = NULL;
- char *rest;
- int argno;
- static char root_name[] = "/";
- char drivername[50];
- const char *preferred_driver = NULL;
- int err_exit = 0;
- hid_t fapl_id = H5P_DEFAULT;
- H5E_auto2_t func;
- H5E_auto2_t tools_func;
- void *edata;
- void *tools_edata;
+ hid_t file_id = H5I_INVALID_HID;
+ char *fname = NULL, *oname = NULL, *x;
+ const char *s = NULL;
+ char *rest;
+ int argno;
+ static char root_name[] = "/";
+ char drivername[50];
+ const char *preferred_driver = NULL;
+ int err_exit = 0;
+ hid_t fapl_id = H5P_DEFAULT;
+ H5E_auto2_t func;
+ H5E_auto2_t tools_func;
+ void *edata;
+ void *tools_edata;
#ifdef H5_HAVE_ROS3_VFD
- /* default "anonymous" s3 configuration */
+ /* Default "anonymous" S3 configuration */
H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
-#endif /* H5_HVAE_ROS3_VFD */
+#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
- /* "default" HDFS configuration */
+ /* "Default" HDFS configuration */
H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -3005,18 +3017,9 @@ main(int argc, const char *argv[])
}
else if (!HDstrncmp(argv[argno], "--s3-cred=", (size_t)10)) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
- usage();
- leave(EXIT_FAILURE);
-#else
- unsigned nelems = 0;
- char *start = NULL;
- char *s3cred_src = NULL;
- char **s3cred = NULL;
- char const *ccred[3];
- /* try to parse s3 credentials tuple
- */
+#ifdef H5_HAVE_ROS3_VFD
+ char const *start = NULL;
+
start = strchr(argv[argno], '=');
if (start == NULL) {
HDfprintf(rawerrorstream, "Error: Unable to parse null credentials tuple\n"
@@ -3025,124 +3028,38 @@ main(int argc, const char *argv[])
leave(EXIT_FAILURE);
}
start++;
- if (FAIL == parse_tuple((const char *)start, ',', &s3cred_src, &nelems, &s3cred)) {
- HDfprintf(rawerrorstream, "Error: Unable to parse S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- /* sanity-check tuple count
- */
- if (nelems != 3) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
- ccred[0] = (const char *)s3cred[0];
- ccred[1] = (const char *)s3cred[1];
- ccred[2] = (const char *)s3cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- HDfprintf(rawerrorstream, "Error: Invalid S3 credentials\n\n");
+
+ if (h5tools_parse_ros3_fapl_tuple(start, ',', &ros3_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse S3 VFD credential info\n\n");
usage();
leave(EXIT_FAILURE);
}
- HDfree(s3cred);
- HDfree(s3cred_src);
-#endif /* H5_HAVE_ROS3_VFD */
-
+#else
+ HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
else if (!HDstrncmp(argv[argno], "--hdfs-attrs=", (size_t)13)) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
- leave(EXIT_FAILURE);
-#else
- /* Parse received configuration data and set fapl config struct */
-
- hbool_t _debug = FALSE;
- unsigned nelems = 0;
- char const *start = NULL;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
-
- /* try to parse tuple
- */
- if (_debug) {
- HDfprintf(stderr, "configuring hdfs...\n");
- }
+#ifdef H5_HAVE_LIBHDFS
+ char const *start = NULL;
+
start = argv[argno]+13; /* should never segfault: worst case of */
if (*start != '(') { /* null-termintor after '='. */
-
- if (_debug) {
- HDfprintf(stderr, " no tuple.\n");
- }
- usage();
- leave(EXIT_FAILURE);
- }
- if (FAIL == parse_tuple((const char *)start, ',', &props_src, &nelems, &props)) {
- HDfprintf(stderr, " unable to parse tuple.\n");
usage();
leave(EXIT_FAILURE);
}
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- HDfprintf(stderr, " expected 5-ple, got `%d`\n", nelems);
+ if (h5tools_parse_hdfs_fapl_tuple(start, ',', &hdfs_fa) < 0) {
+ HDfprintf(rawerrorstream, "Error: failed to parse HDFS VFD configuration info\n\n");
usage();
leave(EXIT_FAILURE);
}
- if (_debug) {
- HDfprintf(stderr, " got hdfs-attrs tuple: `(%s,%s,%s,%s,%s)`\n", props[0], props[1], props[2], props[3], props[4]);
- }
-
- /* Populate fapl configuration structure with given properties.
- * WARNING: No error-checking is done on length of input strings...
- * Silent overflow is possible, albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting namenode name: %s\n", props[0]);
- }
- HDstrncpy(hdfs_fa.namenode_name, (const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed port number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting namenode port: %lu\n", k);
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting kerb cache path: %s\n", props[2]);
- }
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- if (_debug) {
- HDfprintf(stderr, " setting username: %s\n", props[3]);
- }
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (HDstrncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- HDfprintf(stderr, " supposed buffersize number wasn't.\n");
- leave(EXIT_FAILURE);
- }
- if (_debug) {
- HDfprintf(stderr, " setting stream buffer size: %lu\n", k);
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
-#endif /* H5_HAVE_LIBHDFS */
-
+#else
+ HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n");
+ usage();
+ leave(EXIT_FAILURE);
+#endif
}
else if('-'!=argv[argno][1]) {
/* Single-letter switches */
@@ -3236,41 +3153,35 @@ main(int argc, const char *argv[])
}
if (preferred_driver) {
- void *conf_fa = NULL;
+ h5tools_fapl_info_t fapl_info;
- if (!HDstrcmp(preferred_driver, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD not enabled.\n\n");
- usage();
- leave(EXIT_FAILURE);
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ /* Currently, only retrieval of VFDs is supported. */
+ fapl_info.type = VFD_BY_NAME;
+ fapl_info.info = NULL;
+ fapl_info.u.name = preferred_driver;
- }
- else if (!HDstrcmp(preferred_driver, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- PRINTVALSTREAM(rawoutstream, "The HDFS VFD is not enabled.\n");
+ if (!HDstrcmp(preferred_driver, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ fapl_info.info = (void *)&ros3_fa;
+#else
+ HDfprintf(rawerrorstream, "Error: Read-Only S3 VFD is not enabled\n\n");
leave(EXIT_FAILURE);
+#endif
+ }
+ else if (!HDstrcmp(preferred_driver, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ fapl_info.info = (void *)&hdfs_fa;
#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+ HDfprintf(rawerrorstream, "Error: The HDFS VFD is not enabled\n\n");
+ leave(EXIT_FAILURE);
+#endif
}
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- HDfprintf(rawerrorstream, "Error: Unable to create fapl entry\n\n");
- leave(EXIT_FAILURE);
- }
- if (0 == h5tools_set_configured_fapl(fapl_id, preferred_driver, conf_fa)) {
- HDfprintf(rawerrorstream, "Error: Unable to set fapl\n\n");
- usage();
- leave(EXIT_FAILURE);
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) {
+ HDfprintf(rawerrorstream, "Error: Unable to create FAPL for file access\n\n");
+ leave(EXIT_FAILURE);
}
- } /* preferred_driver defined */
+ }
if (enable_error_stack > 0) {
H5Eset_auto2(H5E_DEFAULT, func, edata);
@@ -3301,12 +3212,8 @@ main(int argc, const char *argv[])
file_id = H5I_INVALID_HID;
while (fname && *fname) {
- if (fapl_id != H5P_DEFAULT) {
- file_id = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
- }
- else {
- file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, preferred_driver, drivername, sizeof drivername);
- }
+ file_id = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, drivername, sizeof drivername);
if (file_id >= 0) {
if (verbose_g)
diff --git a/tools/src/h5repack/CMakeLists.txt b/tools/src/h5repack/CMakeLists.txt
index 967e8d7..a4aa1ef 100644
--- a/tools/src/h5repack/CMakeLists.txt
+++ b/tools/src/h5repack/CMakeLists.txt
@@ -17,6 +17,7 @@ set (REPACK_COMMON_SOURCES
if (NOT ONLY_SHARED_LIBS)
add_executable (h5repack ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_main.c)
target_include_directories (h5repack PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repack PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repack STATIC)
target_link_libraries (h5repack PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5repack PROPERTIES FOLDER tools)
@@ -28,6 +29,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5repack-shared ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR}/h5repack_main.c)
target_include_directories (h5repack-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repack-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repack-shared SHARED)
target_link_libraries (h5repack-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5repack-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c
index 8eeaa0e..b2cb02b 100644
--- a/tools/src/h5repack/h5repack.c
+++ b/tools/src/h5repack/h5repack.c
@@ -79,6 +79,8 @@ h5repack_init(pack_opt_t *options, int verbose, hbool_t latest)
options->layout_g = H5D_LAYOUT_ERROR;
options->low_bound = H5F_LIBVER_EARLIEST;
options->high_bound = H5F_LIBVER_LATEST;
+ options->fin_fapl = H5P_DEFAULT;
+ options->fout_fapl = H5P_DEFAULT;
for (n = 0; n < H5_REPACK_MAX_NFILTERS; n++) {
options->filter_g[n].filtn = -1;
@@ -257,7 +259,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
dt->next = *named_dt_head_p;
*named_dt_head_p = dt;
- /* Update the address and id */
+ /* Update the token/address and id */
HDmemcpy(&dt->obj_token, &travt->objs[i].obj_token, sizeof(H5O_token_t));
dt->id_out = H5I_INVALID_HID;
@@ -280,7 +282,7 @@ copy_named_datatype(hid_t type_in, hid_t fidout, named_dt_t **named_dt_head_p, t
dt_ret->next = *named_dt_head_p;
*named_dt_head_p = dt_ret;
- /* Update the address and id */
+ /* Update the token/address and id */
HDmemcpy(&dt_ret->obj_token, &oinfo.token, sizeof(H5O_token_t));
dt_ret->id_out = H5I_INVALID_HID;
} /* end if requested datatype not found */
@@ -751,7 +753,8 @@ check_objects(const char* fname, pack_opt_t *options)
* open the file
*-------------------------------------------------------------------------
*/
- if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0)
+ if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR);
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5repack/h5repack.h b/tools/src/h5repack/h5repack.h
index 52ecb0e..caa1166 100644
--- a/tools/src/h5repack/h5repack.h
+++ b/tools/src/h5repack/h5repack.h
@@ -114,6 +114,8 @@ typedef struct {
hbool_t latest; /*pack file with the latest file format */
H5F_libver_t low_bound; /* The file's low bound as in H5Fset_libver_bounds() */
H5F_libver_t high_bound; /* The file's high bound as in H5Fset_libver_bounds() */
+ hid_t fin_fapl; /* FAPL to use for opening the input file */
+ hid_t fout_fapl; /* FAPL to use for opening/creating the output file */
int grp_compact; /* Set the maximum number of links to store as header messages in the group */
int grp_indexed; /* Set the minimum number of links to store in the indexed format */
int msg_size[8]; /* Minimum size of shared messages: dataspace,
@@ -151,7 +153,7 @@ int h5repack_addlayout(const char* str, pack_opt_t *options);
int h5repack_init(pack_opt_t *options, int verbose, hbool_t latest);
int h5repack_end(pack_opt_t *options);
int h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options);
-int h5repack_cmp_pl(const char *fname1, const char *fname2);
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl);
/* Note: The below copy_named_datatype(), named_datatype_free(), copy_attr()
* and struct named_dt_t were located in h5repack_copy.c as static prior to
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index 1044244..ae93b30 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -67,7 +67,6 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
hid_t grp_in = H5I_INVALID_HID; /* group ID */
hid_t gcpl_in = H5I_INVALID_HID; /* group creation property list */
hid_t fcpl = H5P_DEFAULT; /* file creation property list ID */
- hid_t fapl = H5P_DEFAULT; /* file access property list ID */
trav_table_t *travt = NULL;
hsize_t ub_size = 0; /* size of user block */
H5F_fspace_strategy_t set_strategy; /* Strategy to be set in outupt file */
@@ -85,7 +84,8 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
* open input file
*-------------------------------------------------------------------------
*/
- if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t) 0)) < 0)
+ if ((fidin = h5tools_fopen(fnamein, H5F_ACC_RDONLY, options->fin_fapl,
+ (options->fin_fapl == H5P_DEFAULT) ? FALSE : TRUE, NULL, (size_t) 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fnamein, H5FOPENERROR);
/* get user block size and file space strategy/persist/threshold */
@@ -122,12 +122,14 @@ copy_objects(const char* fnamein, const char* fnameout, pack_opt_t *options)
if(options->latest)
options->low_bound = options->high_bound = H5F_LIBVER_LATEST;
+
/* Create file access property list */
- if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
- H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
+ if (options->fout_fapl == H5P_DEFAULT)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
/* It can be default, latest or other settings by users */
- if(H5Pset_libver_bounds(fapl, options->low_bound, options->high_bound) < 0)
+ if(H5Pset_libver_bounds(options->fout_fapl, options->low_bound, options->high_bound) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_libver_bounds failed to set format version bounds");
/* Check if we need to create a non-default file creation property list */
@@ -218,12 +220,12 @@ print_user_block(fnamein, fidin);
*/
if (options->alignment > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_alignment(fapl, options->threshold, options->alignment) < 0)
+ if (H5Pset_alignment(options->fout_fapl, options->threshold, options->alignment) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_alignment failed to set alignment");
}
@@ -233,12 +235,12 @@ print_user_block(fnamein, fidin);
*/
if (options->meta_block_size > 0) {
/* either use the FAPL already created or create a new one */
- if (fapl == H5P_DEFAULT)
+ if (options->fout_fapl == H5P_DEFAULT)
/* create a file access property list */
- if ((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
+ if ((options->fout_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pcreate failed to create file access property list");
- if (H5Pset_meta_block_size(fapl, options->meta_block_size) < 0)
+ if (H5Pset_meta_block_size(options->fout_fapl, options->meta_block_size) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Pset_meta_block_size failed to set metadata block size");
}
@@ -297,7 +299,7 @@ print_user_block(fnamein, fidin);
if (options->verbose)
HDprintf("Making new file ...\n");
- if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, fapl)) < 0)
+ if ((fidout = H5Fcreate(fnameout, H5F_ACC_TRUNC, fcpl, options->fout_fapl)) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Fcreate could not create file <%s>:", fnameout);
/*-------------------------------------------------------------------------
@@ -352,7 +354,6 @@ done:
H5E_BEGIN_TRY {
H5Pclose(fcpl_in);
H5Pclose(gcpl_in);
- H5Pclose(fapl);
H5Pclose(fcpl);
H5Gclose(grp_in);
H5Fclose(fidin);
@@ -702,11 +703,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *-------------------------------------------------------------------------
+ */
case H5TRAV_TYPE_DATASET:
+ {
+ hbool_t use_h5ocopy;
+
has_filter = 0;
req_filter = 0;
@@ -764,9 +768,47 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
* otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1
+ || options->all_layout == 1 || is_ref || is_named);
+
+ /*
+ * Check if we are using different source and destination VOL connectors.
+ * In this case, we currently have to avoid usage of H5Ocopy since it
+ * doesn't support this.
+ */
+ if (use_h5ocopy && (options->fin_fapl != H5P_DEFAULT || options->fout_fapl != H5P_DEFAULT)) {
+ hid_t in_vol_id;
+ hid_t out_vol_id;
+ hid_t default_vol_id;
+
+ if (H5Pget_vol_id(H5P_FILE_ACCESS_DEFAULT, &default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (options->fin_fapl == H5P_DEFAULT)
+ in_vol_id = default_vol_id;
+ else
+ if (H5Pget_vol_id(options->fin_fapl, &in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+ if (options->fout_fapl == H5P_DEFAULT)
+ out_vol_id = default_vol_id;
+ else
+ if (H5Pget_vol_id(options->fout_fapl, &out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5Pget_vol_id failed");
+
+ if (in_vol_id != out_vol_id)
+ use_h5ocopy = FALSE;
+
+ if (in_vol_id != default_vol_id)
+ if (H5VLclose(in_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (out_vol_id != default_vol_id)
+ if (H5VLclose(out_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ if (H5VLclose(default_vol_id) < 0)
+ H5TOOLS_GOTO_ERROR((-1), "H5VLclose failed");
+ }
+ if (!use_h5ocopy) {
int j;
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
@@ -1135,7 +1177,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
} /* end whether we have request for filter/chunking */
+
break;
+ } /* H5TRAV_TYPE_DATASET */
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_NAMED_DATATYPE
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index 16899a3..1761fb4 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -62,6 +62,12 @@ static struct long_options l_opts[] = {
{ "sort_by", require_arg, 'q' },
{ "sort_order", require_arg, 'z' },
{ "enable-error-stack", no_arg, 'E' },
+ { "src-vol-id", require_arg, '1' },
+ { "src-vol-name", require_arg, '2' },
+ { "src-vol-info", require_arg, '3' },
+ { "dst-vol-id", require_arg, '4' },
+ { "dst-vol-name", require_arg, '5' },
+ { "dst-vol-info", require_arg, '6' },
{ NULL, 0, '\0' }
};
@@ -86,6 +92,18 @@ static void usage(const char *prog) {
PRINTVALSTREAM(rawoutstream, " -n, --native Use a native HDF5 type when repacking\n");
PRINTVALSTREAM(rawoutstream, " --enable-error-stack Prints messages from the HDF5 error stack as they\n");
PRINTVALSTREAM(rawoutstream, " occur\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-id ID of the VOL connector to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-name Name of the VOL connector to use for opening the input\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --src-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the input HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-id ID of the VOL connector to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-name Name of the VOL connector to use for opening the output\n");
+ PRINTVALSTREAM(rawoutstream, " HDF5 file specified\n");
+ PRINTVALSTREAM(rawoutstream, " --dst-vol-info VOL-specific info to pass to the VOL connector used for\n");
+ PRINTVALSTREAM(rawoutstream, " opening the output HDF5 file specified\n");
PRINTVALSTREAM(rawoutstream, " -L, --latest Use latest version of file format\n");
PRINTVALSTREAM(rawoutstream, " This option will take precedence over the options\n");
PRINTVALSTREAM(rawoutstream, " --low and --high\n");
@@ -293,6 +311,8 @@ int read_info(const char *filename, pack_opt_t *options)
/* cycle until end of file reached */
while (1) {
+ if (EOF == fscanf(fp, "%9s", stype))
+ break;
/* Info indicator must be for layout or filter */
if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) {
@@ -334,7 +354,7 @@ int read_info(const char *filename, pack_opt_t *options)
if (!HDstrcmp(stype, "-l")) {
if (h5repack_addlayout(comp_info, options) == -1) {
- error_msg("could not add chunck option\n");
+ error_msg("could not add chunk option\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
goto done;
@@ -412,9 +432,17 @@ set_sort_order(const char *form)
static
int parse_command_line(int argc, const char **argv, pack_opt_t* options)
{
+ h5tools_fapl_info_t in_vol_info;
+ h5tools_fapl_info_t out_vol_info;
+ hbool_t custom_in_fapl = FALSE;
+ hbool_t custom_out_fapl = FALSE;
+ hid_t tmp_fapl = H5I_INVALID_HID;
int bound, opt;
int ret_value = 0;
+ HDmemset(&in_vol_info, 0, sizeof(h5tools_fapl_info_t));
+ HDmemset(&out_vol_info, 0, sizeof(h5tools_fapl_info_t));
+
/* parse command line options */
while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) {
switch ((char) opt) {
@@ -434,13 +462,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'V':
print_version(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'v':
@@ -478,9 +506,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'e':
- ret_value = read_info(opt_arg, options);
- if (ret_value < 0)
+ if ((ret_value = read_info(opt_arg, options)) < 0) {
+ error_msg("failed to read from repack options file <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
+ }
break;
case 'n':
@@ -495,6 +526,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing low bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->low_bound = bound;
@@ -504,6 +537,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing high bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->high_bound = bound;
@@ -625,8 +660,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'q':
- if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) {
- error_msg(" failed to set sort by form <%s>\n", opt_arg);
+ if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) {
+ error_msg("failed to set sort by form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -634,8 +669,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'z':
- if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) {
- error_msg(" failed to set sort order form <%s>\n", opt_arg);
+ if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) {
+ error_msg("failed to set sort order form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
goto done;
@@ -646,6 +681,38 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
enable_error_stack = 1;
break;
+ case '1':
+ in_vol_info.type = VOL_BY_ID;
+ in_vol_info.u.id = HDatol(opt_arg);
+ custom_in_fapl = TRUE;
+ break;
+
+ case '2':
+ in_vol_info.type = VOL_BY_NAME;
+ in_vol_info.u.name = opt_arg;
+ custom_in_fapl = TRUE;
+ break;
+
+ case '3':
+ in_vol_info.info = opt_arg;
+ break;
+
+ case '4':
+ out_vol_info.type = VOL_BY_ID;
+ out_vol_info.u.id = HDatol(opt_arg);
+ custom_out_fapl = TRUE;
+ break;
+
+ case '5':
+ out_vol_info.type = VOL_BY_NAME;
+ out_vol_info.u.name = opt_arg;
+ custom_out_fapl = TRUE;
+ break;
+
+ case '6':
+ out_vol_info.info = opt_arg;
+ break;
+
default:
break;
} /* end switch */
@@ -653,30 +720,71 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
/* If neither -i nor -o given, get in and out files positionally */
if (0 == (has_i + has_o)) {
- if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
- infile = argv[opt_ind];
- outfile = argv[opt_ind + 1];
-
- if (!HDstrcmp(infile, outfile)) {
- error_msg("file names cannot be the same\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else {
- error_msg("file names missing\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
- }
- else if (has_i != 1 || has_o != 1) {
- error_msg("filenames must be either both -i -o or both positional\n");
- usage(h5tools_getprogname());
- h5tools_setstatus(EXIT_FAILURE);
- ret_value = -1;
- }
+ if (argv[opt_ind] != NULL && argv[opt_ind + 1] != NULL) {
+ infile = argv[opt_ind];
+ outfile = argv[opt_ind + 1];
+
+ if (!HDstrcmp(infile, outfile)) {
+ error_msg("file names cannot be the same\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else {
+ error_msg("file names missing\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+ }
+ else if (has_i != 1 || has_o != 1) {
+ error_msg("filenames must be either both -i -o or both positional\n");
+ usage(h5tools_getprogname());
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ }
+
+ /* Setup FAPL for input and output file accesses */
+ if (custom_in_fapl) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fin_fapl, &in_vol_info)) < 0) {
+ error_msg("failed to setup FAPL for input file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fin_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fin_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fin_fapl = tmp_fapl;
+ }
+
+ if (custom_out_fapl) {
+ if ((tmp_fapl = h5tools_get_fapl(options->fout_fapl, &out_vol_info)) < 0) {
+ error_msg("failed to setup FAPL for output file\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ /* Close old FAPL */
+ if (options->fout_fapl != H5P_DEFAULT)
+ if (H5Pclose(options->fout_fapl) < 0) {
+ error_msg("failed to close FAPL\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
+ goto done;
+ }
+
+ options->fout_fapl = tmp_fapl;
+ }
done:
return ret_value;
@@ -694,14 +802,18 @@ done:
*/
int main(int argc, const char **argv)
{
- pack_opt_t options; /*the global options */
+ pack_opt_t options; /*the global options */
H5E_auto2_t func;
H5E_auto2_t tools_func;
void *edata;
void *tools_edata;
+ int parse_ret;
HDmemset(&options, 0, sizeof(pack_opt_t));
+ /* Initialize h5tools lib */
+ h5tools_init();
+
h5tools_setprogname(PROGRAMNAME);
h5tools_setstatus(EXIT_SUCCESS);
@@ -709,29 +821,38 @@ int main(int argc, const char **argv)
H5Eget_auto2(H5E_DEFAULT, &func, &edata);
H5Eset_auto2(H5E_DEFAULT, NULL, NULL);
- /* Initialize h5tools lib */
- h5tools_init();
-
/* Disable tools error reporting */
H5Eget_auto2(H5tools_ERR_STACK_g, &tools_func, &tools_edata);
H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
/* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */
if (h5tools_getenv_update_hyperslab_bufsize() < 0) {
+ HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* initialize options */
if (h5repack_init(&options, 0, FALSE) < 0) {
+ HDprintf("Error occurred while initializing repack options\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
/* Initialize default indexing options */
sort_by = H5_INDEX_CRT_ORDER;
- if (parse_command_line(argc, argv, &options) < 0)
+ parse_ret = parse_command_line(argc, argv, &options);
+ if (parse_ret < 0) {
+ HDprintf("Error occurred while parsing command-line options\n");
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
+ }
+ else if (parse_ret > 0) {
+ /* Short-circuit success */
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ }
if (enable_error_stack > 0) {
H5Eset_auto2(H5E_DEFAULT, func, edata);
@@ -739,9 +860,20 @@ int main(int argc, const char **argv)
}
/* pack it */
- h5tools_setstatus(h5repack(infile, outfile, &options));
+ if (h5repack(infile, outfile, &options) < 0) {
+ HDprintf("Error occurred while repacking\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ h5tools_setstatus(EXIT_SUCCESS);
done:
+ if (options.fin_fapl >= 0 && options.fin_fapl != H5P_DEFAULT)
+ H5Pclose(options.fin_fapl);
+ if (options.fout_fapl >= 0 && options.fout_fapl != H5P_DEFAULT)
+ H5Pclose(options.fout_fapl);
+
/* free tables */
h5repack_end(&options);
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 683988c..7bb5dfd 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -353,16 +353,16 @@ int verify_layout(hid_t pid, pack_info_t *obj)
*-------------------------------------------------------------------------
*/
-int h5repack_cmp_pl(const char *fname1, const char *fname2)
+int h5repack_cmp_pl(const char *fname1, hid_t fname1_fapl, const char *fname2, hid_t fname2_fapl)
{
- hid_t fid1 =H5I_INVALID_HID; /* file ID */
- hid_t fid2 =H5I_INVALID_HID; /* file ID */
- hid_t dset1 =H5I_INVALID_HID; /* dataset ID */
- hid_t dset2 =H5I_INVALID_HID; /* dataset ID */
- hid_t gid =H5I_INVALID_HID; /* group ID */
- hid_t dcpl1 =H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t dcpl2 =H5I_INVALID_HID; /* dataset creation property list ID */
- hid_t gcplid =H5I_INVALID_HID; /* group creation property list */
+ hid_t fid1 = H5I_INVALID_HID; /* file ID */
+ hid_t fid2 = H5I_INVALID_HID; /* file ID */
+ hid_t dset1 = H5I_INVALID_HID; /* dataset ID */
+ hid_t dset2 = H5I_INVALID_HID; /* dataset ID */
+ hid_t gid = H5I_INVALID_HID; /* group ID */
+ hid_t dcpl1 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t dcpl2 = H5I_INVALID_HID; /* dataset creation property list ID */
+ hid_t gcplid = H5I_INVALID_HID; /* group creation property list */
unsigned crt_order_flag1; /* group creation order flag */
unsigned crt_order_flag2; /* group creation order flag */
trav_table_t *trav = NULL;
@@ -374,9 +374,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
*-------------------------------------------------------------------------
*/
/* Open the files */
- if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid1 = h5tools_fopen(fname1, H5F_ACC_RDONLY, fname1_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
- if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ if ((fid2 = h5tools_fopen(fname2, H5F_ACC_RDONLY, fname2_fapl, TRUE, NULL, 0)) < 0)
H5TOOLS_GOTO_ERROR((-1), "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
/*-------------------------------------------------------------------------
diff --git a/tools/src/h5stat/CMakeLists.txt b/tools/src/h5stat/CMakeLists.txt
index f6cc542..f0722fd 100644
--- a/tools/src/h5stat/CMakeLists.txt
+++ b/tools/src/h5stat/CMakeLists.txt
@@ -7,6 +7,7 @@ project (HDF5_TOOLS_SRC_H5STAT C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5stat ${HDF5_TOOLS_SRC_H5STAT_SOURCE_DIR}/h5stat.c)
target_include_directories (h5stat PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5stat PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5stat STATIC)
target_link_libraries (h5stat PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5stat PROPERTIES FOLDER tools)
@@ -18,6 +19,7 @@ endif ()
if (BUILD_SHARED_LIBS)
add_executable (h5stat-shared ${HDF5_TOOLS_SRC_H5STAT_SOURCE_DIR}/h5stat.c)
target_include_directories (h5stat-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5stat-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5stat-shared SHARED)
target_link_libraries (h5stat-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5stat-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/h5stat/h5stat.c b/tools/src/h5stat/h5stat.c
index adc905a..fdf49cd 100644
--- a/tools/src/h5stat/h5stat.c
+++ b/tools/src/h5stat/h5stat.c
@@ -118,30 +118,28 @@ typedef struct iter_t {
} iter_t;
-static const char *drivername = "";
+static const char *drivername = NULL;
#ifdef H5_HAVE_ROS3_VFD
-/* default "anonymous" s3 configuration
- */
+/* Default "anonymous" S3 configuration */
static H5FD_ros3_fapl_t ros3_fa = {
- 1, /* fapl version */
- false, /* authenticate */
- "", /* aws region */
- "", /* access key id */
- "", /* secret access key */
+ 1, /* Structure Version */
+ false, /* Authenticate? */
+ "", /* AWS Region */
+ "", /* Access Key ID */
+ "", /* Secret Access Key */
};
#endif /* H5_HAVE_ROS3_VFD */
#ifdef H5_HAVE_LIBHDFS
-/* default HDFS access configuration
- */
+/* "Default" HDFS configuration */
static H5FD_hdfs_fapl_t hdfs_fa = {
- 1, /* fapl version */
- "localhost", /* namenode name */
- 0, /* namenode port */
- "", /* kerberos ticket cache */
- "", /* user name */
- 2048, /* stream buffer size */
+ 1, /* Structure Version */
+ "localhost", /* Namenode Name */
+ 0, /* Namenode Port */
+ "", /* Kerberos ticket cache */
+ "", /* User name */
+ 2048, /* Stream buffer size */
};
#endif /* H5_HAVE_LIBHDFS */
@@ -1065,103 +1063,32 @@ parse_command_line(int argc, const char *argv[], struct handler_t **hand_ret)
break;
case 'w':
-#ifndef H5_HAVE_ROS3_VFD
+#ifdef H5_HAVE_ROS3_VFD
+ if (h5tools_parse_ros3_fapl_tuple(opt_arg, ',', &ros3_fa) < 0) {
+ error_msg("failed to parse S3 VFD credential info\n");
+ goto error;
+ }
+
+ drivername = drivernames[ROS3_VFD_IDX];
+#else
error_msg("Read-Only S3 VFD not enabled.\n");
goto error;
-#else
- {
- char *cred_str = NULL;
- unsigned nelems = 0;
- char **cred = NULL;
- char const *ccred[3];
-
- if (FAIL == parse_tuple((const char *)opt_arg, ',', &cred_str, &nelems, &cred)) {
- error_msg("Unable to parse s3 credential\n");
- goto error;
- }
- if (nelems != 3) {
- error_msg("s3 credential must have three elements\n");
- goto error;
- }
- ccred[0] = (const char *)cred[0];
- ccred[1] = (const char *)cred[1];
- ccred[2] = (const char *)cred[2];
- if (0 == h5tools_populate_ros3_fapl(&ros3_fa, ccred)) {
- error_msg("Unable to set ros3 fapl config\n");
- goto error;
- }
- HDfree(cred);
- HDfree(cred_str);
- } /* parse s3-cred block */
- drivername = "ros3";
+#endif
break;
-#endif /* H5_HAVE_ROS3_VFD */
case 'H':
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD is not enabled.\n");
- goto error;
-#else
- {
- unsigned nelems = 0;
- char *props_src = NULL;
- char **props = NULL;
- unsigned long k = 0;
- if (FAIL == parse_tuple((const char *)opt_arg,
- ',', &props_src, &nelems, &props)) {
- error_msg("unable to parse hdfs properties tuple\n");
- goto error;
- }
- /* sanity-check tuple count
- */
- if (nelems != 5) {
- char str[64] = "";
- HDsprintf(str,
- "expected 5 elements in hdfs properties tuple "
- "but found %u\n",
- nelems);
- HDfree(props);
- HDfree(props_src);
- error_msg(str);
- goto error;
- }
- /* Populate fapl configuration structure with given
- * properties.
- * TODO/WARNING: No error-checking is done on length of
- * input strings... Silent overflow is possible,
- * albeit unlikely.
- */
- if (HDstrncmp(props[0], "", 1)) {
- HDstrncpy(hdfs_fa.namenode_name,(const char *)props[0], HDstrlen(props[0]));
- }
- if (HDstrncmp(props[1], "", 1)) {
- k = strtoul((const char *)props[1], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed port number wasn't.\n");
- goto error;
- }
- hdfs_fa.namenode_port = (int32_t)k;
- }
- if (HDstrncmp(props[2], "", 1)) {
- HDstrncpy(hdfs_fa.kerberos_ticket_cache, (const char *)props[2], HDstrlen(props[2]));
- }
- if (HDstrncmp(props[3], "", 1)) {
- HDstrncpy(hdfs_fa.user_name, (const char *)props[3], HDstrlen(props[3]));
- }
- if (strncmp(props[4], "", 1)) {
- k = HDstrtoul((const char *)props[4], NULL, 0);
- if (errno == ERANGE) {
- error_msg("supposed buffersize number wasn't.\n");
- goto error;
- }
- hdfs_fa.stream_buffer_size = (int32_t)k;
- }
- HDfree(props);
- HDfree(props_src);
- drivername = "hdfs";
+#ifdef H5_HAVE_LIBHDFS
+ if (h5tools_parse_hdfs_fapl_tuple(opt_arg, ',', &hdfs_fa) < 0) {
+ error_msg("failed to parse HDFS VFD configuration info\n");
+ goto error;
}
+
+ drivername = drivernames[HDFS_VFD_IDX];
+#else
+ error_msg("HDFS VFD not enabled.\n");
+ goto error;
+#endif
break;
-#endif /* H5_HAVE_LIBHDFS */
default:
usage(h5tools_getprogname());
@@ -1885,41 +1812,36 @@ main(int argc, const char *argv[])
if(parse_command_line(argc, argv, &hand) < 0)
goto done;
- /* if drivername is not null, probably need to set the fapl */
- if (HDstrcmp(drivername, "")) {
- void *conf_fa = NULL;
+ if (drivername) {
+ h5tools_fapl_info_t fapl_info;
- if (!HDstrcmp(drivername, "ros3")) {
-#ifndef H5_HAVE_ROS3_VFD
- error_msg("Read-Only S3 VFD not enabled.\n\n");
- goto done;
-#else
- conf_fa = (void *)&ros3_fa;
-#endif /* H5_HAVE_ROS3_VFD */
+ /* Currently, only retrieval of VFDs is supported. */
+ fapl_info.type = VFD_BY_NAME;
+ fapl_info.info = NULL;
+ fapl_info.u.name = drivername;
- }
- else if (!HDstrcmp(drivername, "hdfs")) {
-#ifndef H5_HAVE_LIBHDFS
- error_msg("HDFS VFD not enabled.\n\n");
+ if (!HDstrcmp(drivername, drivernames[ROS3_VFD_IDX])) {
+#ifdef H5_HAVE_ROS3_VFD
+ fapl_info.info = (void *)&ros3_fa;
+#else
+ error_msg("Read-Only S3 VFD not enabled.\n");
goto done;
+#endif
+ }
+ else if (!HDstrcmp(drivername, drivernames[HDFS_VFD_IDX])) {
+#ifdef H5_HAVE_LIBHDFS
+ fapl_info.info = (void *)&hdfs_fa;
#else
- conf_fa = (void *)&hdfs_fa;
-#endif /* H5_HAVE_LIBHDFS */
+ error_msg("HDFS VFD not enabled.\n");
+ goto done;
+#endif
}
- if (conf_fa != NULL) {
- HDassert(fapl_id == H5P_DEFAULT);
- fapl_id = H5Pcreate(H5P_FILE_ACCESS);
- if (fapl_id < 0) {
- error_msg("Unable to create fapl entry\n");
- goto done;
- }
- if (1 > h5tools_set_configured_fapl(fapl_id, drivername, conf_fa)) {
- error_msg("Unable to set fapl\n");
- goto done;
- }
+ if ((fapl_id = h5tools_get_fapl(H5P_DEFAULT, &fapl_info)) < 0) {
+ error_msg("Unable to create FAPL for file access\n");
+ goto done;
}
- } /* drivername set */
+ }
fname = argv[opt_ind];
@@ -1935,7 +1857,9 @@ main(int argc, const char *argv[])
HDprintf("Filename: %s\n", fname);
- fid = H5Fopen(fname, H5F_ACC_RDONLY, fapl_id);
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id,
+ (fapl_id == H5P_DEFAULT) ? FALSE : TRUE, NULL, 0);
+
if(fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
h5tools_setstatus(EXIT_FAILURE);
diff --git a/tools/src/misc/CMakeLists.txt b/tools/src/misc/CMakeLists.txt
index 16e4555..1e9cacc 100644
--- a/tools/src/misc/CMakeLists.txt
+++ b/tools/src/misc/CMakeLists.txt
@@ -8,6 +8,7 @@ project (HDF5_TOOLS_SRC_MISC C)
if (NOT ONLY_SHARED_LIBS)
add_executable (h5debug ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
target_include_directories (h5debug PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5debug PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5debug STATIC)
target_link_libraries (h5debug PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5debug PROPERTIES FOLDER tools)
@@ -15,6 +16,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5repart ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
target_include_directories (h5repart PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart STATIC)
target_link_libraries (h5repart PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5repart PROPERTIES FOLDER tools)
@@ -22,6 +24,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5mkgrp ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
target_include_directories (h5mkgrp PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp STATIC)
target_link_libraries (h5mkgrp PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5mkgrp PROPERTIES FOLDER tools)
@@ -29,6 +32,7 @@ if (NOT ONLY_SHARED_LIBS)
add_executable (h5clear ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
target_include_directories (h5clear PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear STATIC)
target_link_libraries (h5clear PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET})
set_target_properties (h5clear PROPERTIES FOLDER tools)
@@ -45,12 +49,14 @@ if (BUILD_SHARED_LIBS)
add_executable (h5debug-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5debug.c)
target_include_directories (h5debug-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
TARGET_C_PROPERTIES (h5debug-shared SHARED)
+ target_compile_options(h5debug-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
target_link_libraries (h5debug-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5debug-shared PROPERTIES FOLDER tools)
set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};h5debug-shared")
add_executable (h5repart-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5repart.c)
target_include_directories (h5repart-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5repart-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5repart-shared SHARED)
target_link_libraries (h5repart-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5repart-shared PROPERTIES FOLDER tools)
@@ -58,6 +64,7 @@ if (BUILD_SHARED_LIBS)
add_executable (h5mkgrp-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5mkgrp.c)
target_include_directories (h5mkgrp-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5mkgrp-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5mkgrp-shared SHARED)
target_link_libraries (h5mkgrp-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5mkgrp-shared PROPERTIES FOLDER tools)
@@ -65,6 +72,7 @@ if (BUILD_SHARED_LIBS)
add_executable (h5clear-shared ${HDF5_TOOLS_SRC_MISC_SOURCE_DIR}/h5clear.c)
target_include_directories (h5clear-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_compile_options(h5clear-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}")
TARGET_C_PROPERTIES (h5clear-shared SHARED)
target_link_libraries (h5clear-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET})
set_target_properties (h5clear-shared PROPERTIES FOLDER tools)
diff --git a/tools/src/misc/h5clear.c b/tools/src/misc/h5clear.c
index 38fa6a2..2c85e75 100644
--- a/tools/src/misc/h5clear.c
+++ b/tools/src/misc/h5clear.c
@@ -267,6 +267,8 @@ main (int argc, const char *argv[])
/* initialize h5tools lib */
h5tools_init();
+ H5Eset_auto2(H5tools_ERR_STACK_g, NULL, NULL);
+
/* Parse command line options */
if(parse_command_line(argc, argv) < 0)
goto done;
@@ -339,7 +341,7 @@ main (int argc, const char *argv[])
}
/* Open the file */
- if((fid = h5tools_fopen(fname, flags, fapl, NULL, NULL, (size_t)0)) < 0) {
+ if((fid = h5tools_fopen(fname, flags, fapl, FALSE, NULL, (size_t)0)) < 0) {
error_msg("h5tools_fopen\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
diff --git a/tools/src/misc/h5mkgrp.c b/tools/src/misc/h5mkgrp.c
index feb60d4..a2cb68b 100644
--- a/tools/src/misc/h5mkgrp.c
+++ b/tools/src/misc/h5mkgrp.c
@@ -255,7 +255,7 @@ main(int argc, const char *argv[])
} /* end if */
/* Attempt to open an existing HDF5 file first */
- fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, NULL, NULL, 0);
+ fid = h5tools_fopen(params.fname, H5F_ACC_RDWR, fapl_id, FALSE, NULL, 0);
/* If we couldn't open an existing file, try creating file */
/* (use "EXCL" instead of "TRUNC", so we don't blow away existing non-HDF5 file) */
diff --git a/tools/test/h5format_convert/h5fc_chk_idx.c b/tools/test/h5format_convert/h5fc_chk_idx.c
index ad1742b..02cc25f 100644
--- a/tools/test/h5format_convert/h5fc_chk_idx.c
+++ b/tools/test/h5format_convert/h5fc_chk_idx.c
@@ -60,7 +60,7 @@ main(int argc, char *argv[])
dname = HDstrdup(argv[2]);
/* Try opening the file */
- if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) {
HDfprintf(stderr, "h5fc_chk_idx: unable to open the file\n");
HDexit(EXIT_FAILURE);
} /* end if */
diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in
index 2cdd445..d780a3d 100644
--- a/tools/test/h5format_convert/testh5fc.sh.in
+++ b/tools/test/h5format_convert/testh5fc.sh.in
@@ -483,7 +483,7 @@ TOOLTEST_OUT h5fc_v_n_all.ddl h5fc_non_v3.h5 -v -n
#
#
# h5format_convert -v h5fc_err_level.h5 (error encountered in converting the dataset)
-TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v
+TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v --enable-error-stack
#
#
#
diff --git a/tools/test/h5repack/h5repack.sh.in b/tools/test/h5repack/h5repack.sh.in
index 6e63136..ad6fef8 100644
--- a/tools/test/h5repack/h5repack.sh.in
+++ b/tools/test/h5repack/h5repack.sh.in
@@ -745,7 +745,7 @@ TOOLTEST1()
TESTING $H5REPACK $@
(
cd $TESTDIR
- $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile
+ $ENVCMD $RUNSERIAL $H5REPACK_BIN "$@" $infile $outfile
)
RET=$?
if [ $RET != 0 ] ; then
diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c
index 2654685..ac1fbe0 100644
--- a/tools/test/h5repack/h5repacktst.c
+++ b/tools/test/h5repack/h5repacktst.c
@@ -382,7 +382,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME0, FNAME0OUT, &pack_options) <= 0)
GOERROR;
- if (h5repack_cmp_pl(FNAME0, FNAME0OUT) <= 0)
+ if (h5repack_cmp_pl(FNAME0, pack_options.fin_fapl, FNAME0OUT, pack_options.fout_fapl) <= 0)
GOERROR;
if (h5repack_end(&pack_options) < 0)
GOERROR;
@@ -402,7 +402,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME1, FNAME1OUT, &pack_options) <= 0)
GOERROR;
- if (h5repack_cmp_pl(FNAME1, FNAME1OUT) <= 0)
+ if (h5repack_cmp_pl(FNAME1, pack_options.fin_fapl, FNAME1OUT, pack_options.fout_fapl) <= 0)
GOERROR;
if (h5repack_end(&pack_options) < 0)
GOERROR;
@@ -422,7 +422,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME2, FNAME2OUT, &pack_options) <= 0)
GOERROR;
- if (h5repack_cmp_pl(FNAME2, FNAME2OUT) <= 0)
+ if (h5repack_cmp_pl(FNAME2, pack_options.fin_fapl, FNAME2OUT, pack_options.fout_fapl) <= 0)
GOERROR;
if (h5repack_end(&pack_options) < 0)
GOERROR;
@@ -441,7 +441,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME3, FNAME3OUT, &pack_options) <= 0)
GOERROR;
- if (h5repack_cmp_pl(FNAME3, FNAME3OUT) <= 0)
+ if (h5repack_cmp_pl(FNAME3, pack_options.fin_fapl, FNAME3OUT, pack_options.fout_fapl) <= 0)
GOERROR;
if (h5repack_end(&pack_options) < 0)
GOERROR;
@@ -1132,7 +1132,7 @@ int main (void)
GOERROR;
if (h5repack_verify(FNAME7, FNAME7OUT, &pack_options) <= 0)
GOERROR;
- if (h5repack_cmp_pl(FNAME7, FNAME7OUT) <= 0)
+ if (h5repack_cmp_pl(FNAME7, pack_options.fin_fapl, FNAME7OUT, pack_options.fout_fapl) <= 0)
GOERROR;
if (h5repack_end(&pack_options) < 0)
GOERROR;
diff --git a/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl b/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl
index 5a141aa..7cab02b 100644
--- a/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl
+++ b/tools/test/h5repack/testfiles/attrregion.tattrreg.h5.ddl
@@ -6,7 +6,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
diff --git a/tools/test/h5repack/testfiles/h5repack-help.txt b/tools/test/h5repack/testfiles/h5repack-help.txt
index 130cd72..fe02584 100644
--- a/tools/test/h5repack/testfiles/h5repack-help.txt
+++ b/tools/test/h5repack/testfiles/h5repack-help.txt
@@ -8,6 +8,18 @@ usage: h5repack [OPTIONS] file1 file2
-n, --native Use a native HDF5 type when repacking
--enable-error-stack Prints messages from the HDF5 error stack as they
occur
+ --src-vol-id ID of the VOL connector to use for opening the input
+ HDF5 file specified
+ --src-vol-name Name of the VOL connector to use for opening the input
+ HDF5 file specified
+ --src-vol-info VOL-specific info to pass to the VOL connector used for
+ opening the input HDF5 file specified
+ --dst-vol-id ID of the VOL connector to use for opening the output
+ HDF5 file specified
+ --dst-vol-name Name of the VOL connector to use for opening the output
+ HDF5 file specified
+ --dst-vol-info VOL-specific info to pass to the VOL connector used for
+ opening the output HDF5 file specified
-L, --latest Use latest version of file format
This option will take precedence over the options
--low and --high
diff --git a/tools/test/misc/clear_open_chk.c b/tools/test/misc/clear_open_chk.c
index 3a61385..7d22ca6 100644
--- a/tools/test/misc/clear_open_chk.c
+++ b/tools/test/misc/clear_open_chk.c
@@ -53,7 +53,7 @@ main(int argc, char *argv[])
fname = HDstrdup(argv[1]);
/* Try opening the file */
- if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, (size_t)0)) < 0) {
+ if((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, FALSE, NULL, (size_t)0)) < 0) {
HDfprintf(stderr, "clear_open_chk: unable to open the file\n");
HDfree(fname);
HDexit(EXIT_FAILURE);
diff --git a/tools/testfiles/tgrpnullspace.ddl b/tools/testfiles/tgrpnullspace.ddl
index 2b91527..7c1ef6c 100644
--- a/tools/testfiles/tgrpnullspace.ddl
+++ b/tools/testfiles/tgrpnullspace.ddl
@@ -13,7 +13,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
diff --git a/tools/testfiles/tintsnodata.ddl b/tools/testfiles/tintsnodata.ddl
index c20f337..a1516af 100644
--- a/tools/testfiles/tintsnodata.ddl
+++ b/tools/testfiles/tintsnodata.ddl
@@ -6,7 +6,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -35,7 +35,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -64,7 +64,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -101,7 +101,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -154,7 +154,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -183,7 +183,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -212,7 +212,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -249,7 +249,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE
@@ -302,7 +302,7 @@ GROUP "/" {
STORAGE_LAYOUT {
CONTIGUOUS
SIZE 0
- OFFSET 18446744073709551615
+ OFFSET HADDR_UNDEF
}
FILTERS {
NONE