diff options
author | Jacob Smith <jake.smith@hdfgroup.org> | 2020-04-07 15:22:21 (GMT) |
---|---|---|
committer | Jacob Smith <jake.smith@hdfgroup.org> | 2020-04-07 15:29:00 (GMT) |
commit | 075e74e9b2e2ad761af44237aa78acc6ff3c3c24 (patch) | |
tree | 8511d081cc709a57790b4e92eb75571352ef40d3 | |
parent | d97c00013dd5b13b618d08d9b6d6517176674a4e (diff) | |
parent | b27a20f8c0e286ea7c2836605632ea2ee5522d03 (diff) | |
download | hdf5-075e74e9b2e2ad761af44237aa78acc6ff3c3c24.zip hdf5-075e74e9b2e2ad761af44237aa78acc6ff3c3c24.tar.gz hdf5-075e74e9b2e2ad761af44237aa78acc6ff3c3c24.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/~jake.smith/hdf5 into feature/vfd_splitter_mirror_a
167 files changed, 4910 insertions, 3227 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d2eea72..7d6e7a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -979,6 +979,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) message (STATUS "Fortran compiler ID is ${CMAKE_Fortran_COMPILER_ID}") + include (${HDF_RESOURCES_DIR}/HDFFortranCompilerFlags.cmake) include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) set (LINK_Fortran_LIBS ${LINK_LIBS}) @@ -1020,6 +1021,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/c++" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/c++") endif () include (${HDF_RESOURCES_EXT_DIR}/HDFUseCXX.cmake) + include (${HDF_RESOURCES_DIR}/HDFCXXCompilerFlags.cmake) if (CMAKE_NO_STD_NAMESPACE) set (H5_NO_STD 1) @@ -143,10 +143,55 @@ ./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/intel-warnings-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/cxx-general +./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/gfort-general +./config/gnu-warnings/gfort-4.4 +./config/gnu-warnings/gfort-4.5 +./config/gnu-warnings/gfort-4.7 +./config/gnu-warnings/gfort-4.8 +./config/gnu-warnings/gfort-5 +./config/gnu-warnings/gfort-6 +./config/gnu-warnings/gfort-8 +./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/ifort-general +./config/intel-warnings/general ./config/site-specific/BlankForm @@ -3376,6 +3421,8 @@ ./config/cmake/hdf5-config.cmake.in ./config/cmake/hdf5-config-version.cmake.in ./config/cmake/HDFCompilerFlags.cmake +./config/cmake/HDFCXXCompilerFlags.cmake +./config/cmake/HDFFortranCompilerFlags.cmake ./config/cmake/HDF5_Process_Flex_Files.cmake ./config/cmake/HDF5Macros.cmake ./config/cmake/HDF5UseFortran.cmake @@ -133,6 +133,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..058f457 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -90,6 +90,7 @@ 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 +108,7 @@ 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/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index 29534a7..ca2295e 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -39,6 +39,7 @@ configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @O add_executable (cpp_testhdf5 ${CPP_TEST_SOURCES} ) target_include_directories (cpp_testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +target_compile_options(cpp_testhdf5 PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_compile_definitions(cpp_testhdf5 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/CTestCustom.cmake b/config/cmake/CTestCustom.cmake index 7f71e8d..725e382 100644 --- a/config/cmake/CTestCustom.cmake +++ b/config/cmake/CTestCustom.cmake @@ -18,23 +18,18 @@ set (CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE 50000) set (CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} -# "H5detect.c.[0-9]+.[ \t]*:[ \t]*warning C4090:" -# "H5detect.c.[0-9]+.[ \t]*:[ \t]*warning:[ \t]*passing argument" -# "H5detect.c[0-9 \t:]*warning:[ \t]*passing argument" "note.*expected.*void.*but argument is of type.*volatile" -# "H5Tconv.c[0-9 \t:]*warning:[ \t]*comparison is always false due to limited range of data type" -# "H5Ztrans.c.[0-9]+.[ \t]*:[ \t]*warning C4244" "src.ZLIB.*:[ \t]*warning" "warning LNK4197:.*ZLIB-prefix" "src.SZIP.*:[ \t]*warning" # "POSIX name for this item is deprecated" "disabling jobserver mode" "config.cmake.xlatefile.c" -# "warning.*implicit declaration of function" "warning.*unknown pragma" "warning.*unrecognized .pragma" # "note: expanded from macro" -# "fpp:[ \t]*warning:[ \t]*cannot remove H5_DEBUG_API - not a predefined macro" + # HDDFFV-11074 + "This directive is not standard" ) set (CTEST_CUSTOM_MEMCHECK_IGNORE diff --git a/config/cmake/HDFCXXCompilerFlags.cmake b/config/cmake/HDFCXXCompilerFlags.cmake new file mode 100644 index 0000000..bf22886 --- /dev/null +++ b/config/cmake/HDFCXXCompilerFlags.cmake @@ -0,0 +1,326 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +set(CMAKE_CXX_STANDARD 98) +set(CMAKE_CXX_STANDARD_REQUIRED TRUE) +set(CMAKE_CXX_EXTENSIONS OFF) + +macro (ADD_H5_FLAGS h5_flag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_flag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_flag_var=${${h5_flag_var}}") +endmacro () + +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_SANITIZER_FLAGS} ${CMAKE_CXX_FLAGS}") +message (STATUS "Warnings Configuration: CXX default: ${CMAKE_CXX_FLAGS}") +#----------------------------------------------------------------------------- +# Compiler specific flags : Shouldn't there be compiler tests for these +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}") + if (${HDF_CFG_NAME} MATCHES "Debug") + if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") + endif () + else () + if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstdarg-opt") + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + 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} /W0") + endif () + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") + endif () + endif () +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) + if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + list (APPEND HDF5_CMAKE_CXX_FLAGS "-erroff=%none -DBSD_COMP") + else () + # General flags + # + # 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 at configure time. + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/general") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 18.0) + list (APPEND H5_CXXFLAGS0 "-Wextra-tokens -Wformat -Wformat-security -Wic-pointer -Wshadow") + list (APPEND H5_CXXFLAGS0 "-Wsign-compare -Wtrigraphs -Wwrite-strings") + endif() + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/cxx-general") + endif () + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + ADD_H5_FLAGS (HDF5_CMAKE_CXX_FLAGS "${HDF5_SOURCE_DIR}/config/clang-warnings/general") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_CXX_FLAGS "-Minform=inform") + endif () + message (STATUS "CMAKE_CXX_FLAGS_GENERAL=${HDF5_CMAKE_CXX_FLAGS}") + endif () + + #----------------------------------------------------------------------------- + # Option to allow the user to enable developer warnings + # Developer warnings (suggestions from gcc, not code problems) + #----------------------------------------------------------------------------- + #if (HDF5_ENABLE_DEV_WARNINGS) + # message (STATUS "....HDF5 developer group warnings are enabled") + # if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + # list (APPEND H5_CXXFLAGS0 "-Winline -Wreorder -Wport -Wstrict-aliasing") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-general") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/developer-general") + # endif () + #else () + # if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-general") + # elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + # ADD_H5_FLAGS (H5_CXXFLAGS0 "${HDF5_SOURCE_DIR}/config/clang-warnings/no-developer-general") + # endif () + #endif () + + + #if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # # Append warning flags that only gcc 4.3+ knows about + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.3") + + # # Append more extra warning flags that only gcc 4.4+ know about + # if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.4") + # endif () + #endif () + + # Append more extra warning flags that only gcc 4.5+ know about + #if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.5) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/4.5") + # if (HDF5_ENABLE_DEV_WARNINGS) + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/developer-4.5") + # else () + # ADD_H5_FLAGS (H5_CXXFLAGS1 "${HDF5_SOURCE_DIR}/config/gnu-warnings/no-developer-4.5") + # endif () + #endif () +else () + list (APPEND HDF5_CMAKE_CXX_FLAGS "/EHsc") +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable all warnings +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_ALL_WARNINGS) + message (STATUS "....All Warnings are enabled") + if (MSVC) + if (HDF5_ENABLE_DEV_WARNINGS) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/Wall /wd4668") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") + endif () + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CXXFLAGS0} ${H5_CXXFLAGS1} ${H5_CXXFLAGS2} ${H5_CXXFLAGS3} ${H5_CXXFLAGS4}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPZERO_WARNINGS) + message (STATUS "....Group Zero warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W1") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS0}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPONE_WARNINGS) + message (STATUS "....Group One warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W2") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS1}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPTWO_WARNINGS) + message (STATUS "....Group Two warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W3") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS2}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPTHREE_WARNINGS) + message (STATUS "....Group Three warnings are enabled") + if (MSVC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_CXX_FLAGS "${HDF5_CMAKE_CXX_FLAGS}") + list (APPEND HDF5_CMAKE_CXX_FLAGS "/W4") + endif () + else () + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS3}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option to allow the user to enable warnings by groups +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_GROUPFOUR_WARNINGS) + message (STATUS "....Group Four warnings are enabled") + if (NOT MSVC) + if (CMAKE_COMPILER_IS_GNUCC) + if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS ${H5_CFLAGS4}) + endif () + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# This is in here to help some of the GCC based IDES like Eclipse +# and code blocks parse the compiler errors and warnings better. +#----------------------------------------------------------------------------- +if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-symbols +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_SYMBOLS MATCHES "YES") + if(CMAKE_CXX_COMPILER_LOADED) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + endif () + endif () +elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") + if(CMAKE_CXX_COMPILER_LOADED) + if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") + set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") + elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") + endif () + endif () +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-profiling +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_PROFILING) + if(CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS "${PROFILE_CXXFLAGS}") + endif () +endif () + +#----------------------------------------------------------------------------- +# Option for --enable-optimization +# This option will force/override the default setting for all configurations +#----------------------------------------------------------------------------- +if (HDF5_ENABLE_OPTIMIZATION) + if(CMAKE_CXX_COMPILER_LOADED) + list (APPEND HDF5_CMAKE_CXX_FLAGS "${OPTIMIZE_CXXFLAGS}") + endif () +endif () diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 17b0854..b255e22 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 () @@ -49,18 +49,6 @@ if (CMAKE_COMPILER_IS_GNUCC) endif () endif () endif () -if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}") - if (${HDF_CFG_NAME} MATCHES "Debug") - if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") - endif () - else () - if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstdarg-opt") - endif () - endif () -endif () #----------------------------------------------------------------------------- # Option to allow the user to disable compiler warnings @@ -74,10 +62,6 @@ if (HDF5_DISABLE_COMPILER_WARNINGS) set (HDF5_WARNINGS_BLOCKED 1) string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W0") - 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} /W0") - endif () endif () if (WIN32) add_definitions (-D_CRT_SECURE_NO_WARNINGS) @@ -91,19 +75,20 @@ if (HDF5_DISABLE_COMPILER_WARNINGS) # Most compilers use -w to suppress warnings. if (NOT HDF5_WARNINGS_BLOCKED) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w") - if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - endif () endif () 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,33 +100,29 @@ 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") + 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") + 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") + 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 () + message (STATUS "CMAKE_C_FLAGS_GENERAL=${HDF5_CMAKE_C_FLAGS}") endif () #----------------------------------------------------------------------------- @@ -152,100 +133,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 +265,14 @@ 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") - 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") - endif () + list (APPEND HDF5_CMAKE_C_FLAGS "/Wall /wd4668") else () string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set (CMAKE_C_FLAGS "${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") - endif () + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") 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 +284,11 @@ 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") - 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") - endif () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W1") 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 +300,12 @@ 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") - 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") - endif () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W2") else () - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS1}") + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS1}) + endif () endif () endif () @@ -322,14 +316,12 @@ 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") - 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") - endif () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W3") else () - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS2}") + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS2}) + endif () endif () endif () @@ -340,14 +332,12 @@ 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") - 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") - endif () + string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " HDF5_CMAKE_C_FLAGS "${HDF5_CMAKE_C_FLAGS}") + list (APPEND HDF5_CMAKE_C_FLAGS "/W4") else () - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${H5_CFLAGS3}") + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS3}) + endif () endif () endif () @@ -358,7 +348,9 @@ 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}") + if (CMAKE_COMPILER_IS_GNUCC) + list (APPEND HDF5_CMAKE_C_FLAGS ${H5_CFLAGS4}) + endif () endif () endif () @@ -369,9 +361,6 @@ endif () if (CMAKE_COMPILER_IS_GNUCC) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0") endif () -if (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0") -endif () #----------------------------------------------------------------------------- # Option for --enable-asserts @@ -401,26 +390,12 @@ if (HDF5_ENABLE_SYMBOLS MATCHES "YES") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fno-omit-frame-pointer") endif () - if(CMAKE_CXX_COMPILER_LOADED) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") - endif () - endif () elseif (HDF5_ENABLE_SYMBOLS MATCHES "NO") if (CMAKE_C_COMPILER_ID STREQUAL "Intel") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") elseif (CMAKE_C_COMPILER_ID STREQUAL "GNU") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s") endif () - if(CMAKE_CXX_COMPILER_LOADED) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel") - set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wl,-s") - elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s") - endif () - endif () endif () MARK_AS_ADVANCED (HDF5_ENABLE_SYMBOLS) @@ -430,10 +405,7 @@ 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}") - if(CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PROFILE_CXXFLAGS}") - endif () + list (APPEND HDF5_CMAKE_C_FLAGS "${PROFILE_CFLAGS}") endif () MARK_AS_ADVANCED (HDF5_ENABLE_PROFILING) @@ -443,9 +415,6 @@ 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}") - if(CMAKE_CXX_COMPILER_LOADED) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZE_CXXFLAGS}") - endif () + list (APPEND HDF5_CMAKE_C_FLAGS "${OPTIMIZE_CFLAGS}") endif () MARK_AS_ADVANCED (HDF5_ENABLE_OPTIMIZATION) diff --git a/config/cmake/HDFFortranCompilerFlags.cmake b/config/cmake/HDFFortranCompilerFlags.cmake new file mode 100644 index 0000000..f31eba5 --- /dev/null +++ b/config/cmake/HDFFortranCompilerFlags.cmake @@ -0,0 +1,142 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +macro (ADD_H5_FFLAGS h5_fflag_var infile) + file (STRINGS ${infile} TEST_FLAG_STREAM) + #message (STATUS "TEST_FLAG_STREAM=${TEST_FLAG_STREAM}") + list (LENGTH TEST_FLAG_STREAM len_flag) + if (len_flag GREATER 0) + math (EXPR _FP_LEN "${len_flag} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET TEST_FLAG_STREAM ${line} str_flag) + string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}") + #message (STATUS "str_flag=${str_flag}") + if (str_flag) + list (APPEND ${h5_fflag_var} "${str_flag}") + endif () + endforeach () + endif () + #message (STATUS "h5_fflag_var=${${h5_fflag_var}}") +endmacro () + +message (STATUS "Warnings Configuration: default Fortran: ${CMAKE_Fortran_FLAGS}") + +#----------------------------------------------------------------------------- +# Option to allow the user to disable compiler warnings +#----------------------------------------------------------------------------- +if (HDF5_DISABLE_COMPILER_WARNINGS) + message (STATUS "....Compiler warnings are suppressed") + # MSVC uses /w to suppress warnings. It also complains if another + # warning level is given, so remove it. + if (MSVC) + set (HDF5_WARNINGS_BLOCKED 1) + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} /warn:none") + endif () + endif () + if (WIN32) + add_definitions (-D_CRT_SECURE_NO_WARNINGS) + endif () + # Borland uses -w- to suppress warnings. + if (BORLAND) + set (HDF5_WARNINGS_BLOCKED 1) + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w-") + endif () + + # Most compilers use -w to suppress warnings. + if (NOT HDF5_WARNINGS_BLOCKED) + set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -w") + endif () +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) + # General flags + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/ifort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-stand:f03" "-free") + elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-ffree-form" "-std=f2008" "-fimplicit-none") + elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "-Mfreeform" "-Mdclchk" "-Mstandard" "-Mallocatable=03") + endif () + message (STATUS "HDF5_CMAKE_Fortran_FLAGS=${HDF5_CMAKE_Fortran_FLAGS}") + + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") + # Append warning flags that only gcc 4.4+ knows about + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.4") + endif () + + # Append more extra warning flags that only gcc 4.5+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.5) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.5") + endif () + + # Append more extra warning flags that only gcc 4.6+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.6) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.6") + #endif () + + # Append more extra warning flags that only gcc 4.7+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.7) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.7") + endif () + + # Append more extra warning flags that only gcc 4.8+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.8) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.8") + endif () + + # Append more extra warning flags that only gcc 4.9+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 4.9) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-4.9") + #endif () + + # Append more extra warning flags that only gcc 5.1+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-5") + endif () + + # Append more extra warning flags that only gcc 6.x+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 6.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-6") + endif () + + # Append more extra warning flags that only gcc 7.x+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-7") + #endif () + + # Append more extra warning flags that only gcc 8.x+ know about + if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 8.0) + ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-8") + endif () + + # Append more extra warning flags that only gcc 9.x+ know about + #if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 9.0) + # ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/gnu-warnings/gfort-9") + #endif () +else () + if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel") + #ADD_H5_FLAGS (HDF5_CMAKE_Fortran_FLAGS "${HDF5_SOURCE_DIR}/config/intel-warnings/win-ifort-general") + list (APPEND HDF5_CMAKE_Fortran_FLAGS "/warn:all" "/stand:f03" "/free") + endif () +endif () + diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index 190fce2..b745765 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@ @@ -46,7 +46,7 @@ Languages: Fortran: @HDF5_BUILD_FORTRAN@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Compiler: @CMAKE_Fortran_COMPILER@ @CMAKE_Fortran_COMPILER_VERSION@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Flags: @CMAKE_Fortran_FLAGS@ -@BUILD_FORTRAN_CONDITIONAL_TRUE@ H5 Fortran Flags: @H5_FCFLAGS@ +@BUILD_FORTRAN_CONDITIONAL_TRUE@ H5 Fortran Flags: @HDF5_CMAKE_Fortran_FLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ AM Fortran Flags: @AM_FCFLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Shared Fortran Library: @H5_ENABLE_SHARED_LIB@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Static Fortran 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 7a033f4..0875aad 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 @@ -275,11 +276,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) @@ -330,7 +331,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 () @@ -440,14 +441,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 ) @@ -455,20 +460,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-cxxflags b/config/gnu-cxxflags index f8a6d8c..9ae38f6 100644 --- a/config/gnu-cxxflags +++ b/config/gnu-cxxflags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -17,19 +17,51 @@ # if the compiler is not GNU; otherwise `cxx_flags_set' is set to `yes' # +# +# 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-warnings/` 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, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_gnu_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for g++ # unless a compiler version is already known # # cxx_vendor: The compiler name: g++ # cxx_version: Version number: 2.91.60, 2.7.2.1 # -if test X = "X$cxx_flags_set"; then +if test "X-" = "X-$cxx_flags_set"; then # PathScale compiler spits out gcc version string too. Need to # filter it out. # icc beginning with version 12 includes a "gcc version compatiblilty" - # string, causing the gcc H5_CFLAGS to be erroneously added. The line + # string, causing the gcc H5_CXXFLAGS to be erroneously added. The line # "grep -v 'icc version'" causes the discarding of any output - # containing 'icc version'. The cc_version for icc is correctly determined + # containing 'icc version'. The cxx_version for icc is correctly determined # and flags added in the intel-flags script. cxx_version="`$CXX $CXXFLAGS $H5_CXXFLAGS -v 2>&1 | grep -v 'PathScale' |\ grep -v '^icc.*version' |\ @@ -37,13 +69,13 @@ if test X = "X$cxx_flags_set"; then cxx_vendor=`echo $cxx_version |sed 's/\([a-z]*\).*/\1/'` cxx_version=`echo $cxx_version |sed 's/[-a-z]//g'` if test X = "X$cxx_vendor" -a X != "X$cxx_version"; then - cxx_vendor=g++ + cxx_vendor=g++ fi if test "-" != "$cxx_vendor-$cxx_version"; then - echo "compiler '$CXX' is GNU $cxx_vendor-$cxx_version" + echo "compiler '$CXX' is GNU $cxx_vendor-$cxx_version" fi - # Some version numbers + # Get the compiler version numbers cxx_vers_major=`echo $cxx_version | cut -f1 -d.` cxx_vers_minor=`echo $cxx_version | cut -f2 -d.` cxx_vers_patch=`echo $cxx_version | cut -f3 -d.` @@ -53,10 +85,12 @@ if test X = "X$cxx_flags_set"; then cxx_vers_all=`expr $cxx_vers_major '*' 1000000 + $cxx_vers_minor '*' 1000 + $cxx_vers_patch` fi -# Common g++ flags for various situations -case "$cxx_vendor-$cxx_version" in - g++*) - # Architecture-specific flags +if test "X-g++" = "X-$cxx_vendor"; then + + ############################### + # Architecture-specific flags # + ############################### + arch= case "$host_os-$host_cpu" in # FreeBSD sets the information from "uname -m" to the general machine @@ -84,742 +118,197 @@ case "$cxx_vendor-$cxx_version" in ;; esac - # Host-specific flags - case "`hostname`" in - sleipnir.ncsa.uiuc.edu) - arch="$arch -pipe" - ;; - esac - - # General (copied from H5_CFLAGS) - H5_CXXFLAGS="$H5_CXXFLAGS $arch -pedantic -Wall -W -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wredundant-decls -Winline" - # C++-specific - H5_CXXFLAGS="$H5_CXXFLAGS -Wsign-promo -Woverloaded-virtual -Wold-style-cast -Weffc++ -Wreorder -Wnon-virtual-dtor -Wctor-dtor-privacy -Wabi" + H5_CXXFLAGS="$H5_CXXFLAGS $arch + + ############## + # Production # + ############## - # Production # NDEBUG is handled explicitly by the configure script - case "$cxx_vendor-$cxx_version" in - g++-[34].*) + if test $cxx_vers_major -le 4; then PROD_CXXFLAGS= - ;; - g++-[56].*) + else PROD_CXXFLAGS="-fstdarg-opt" - ;; - *) - PROD_CXXFLAGS="-finline-functions" - ;; - esac + fi + + ######### + # Debug # + ######### - # Debug # NDEBUG is handled explicitly by the configure script - # -g is hanled by the symbols flags - case "$cxx_vendor-$cxx_version" in - g++-[56].*) - DEBUG_CXXFLAGS="-ftrapv -fno-common" - ;; - *) + # -g is handled by the symbols flags + if test $cxx_vers_major -le 4; then DEBUG_CXXFLAGS= - ;; - esac + else + DEBUG_CXXFLAGS="-ftrapv -fno-common" + fi + + ########### + # Symbols # + ########### - # Symbols NO_SYMBOLS_CXXFLAGS="-s" SYMBOLS_CXXFLAGS="-g" - # Profile + ############# + # Profiling # + ############# + PROFILE_CXXFLAGS="-pg" - # Optimization - case "$cxx_vendor-$cxx_version" in - g++-[34].*) + ################ + # Optimization # + ################ + + if test $cxx_vers_major -le 4; then HIGH_OPT_CXXFLAGS="-O3" DEBUG_OPT_CXXFLAGS= - ;; - g++-[56].*) + else HIGH_OPT_CXXFLAGS="-O3" DEBUG_OPT_CXXFLAGS="-Og" - ;; - *) - HIGH_OPT_CXXFLAGS="-O" - DEBUG_OPT_CXXFLAGS= - ;; - esac + fi NO_OPT_CXXFLAGS="-O0" - # Flags are set - cxx_flags_set=yes - ;; -esac - -# Version-specific g++ flags -# -# Please follow the pattern below by adding new versions at the top, copying -# the information from the previous version and adding modifications to that. -case "$cxx_vendor-$cxx_version" in - -# Closer to the g++ 5.2 release, we should check for additional flags to -# include and break it out into it's own section, like the other versions -# below. -QAK - g++-[56]*) + ############ + # Warnings # + ############ - # Append warning flags from gcc-3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" +# First load the C warnings then add CXX warnings (if needed) - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" + ########### + # General # + ########### - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments general)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-general)" + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments cxx-general)" + #H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-cxx-general)" - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" + ###################### + # Developer warnings # + ###################### - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" + NO_DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments no-developer-general) + DEVELOPER_WARNING_CXXFLAGS=$(load_gnu_arguments developer-general) - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" + ####################### + # gcc 4 special cases # + ####################### - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" + # 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_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.6)" + fi - # Append more extra warning flags that only gcc 4.9+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdate-time -Wopenmp-simd" + # 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_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.3)" + fi - # (There was no release of gcc 5.0) + # 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_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5-4.6)" + fi - # Append more extra warning flags that only gcc 5.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Warray-bounds=2" - ;; + # 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_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.4)" + fi - g++-4.9*) - # Append warning flags + # 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_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.2-4.last)" + fi - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" + ############################# + # Version-specific warnings # + ############################# - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" + # gcc >= 4.3 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 3; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.3)" + fi - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" + # gcc >= 4.4 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 4; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.4)" + fi - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" + # gcc >= 4.5 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 5; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.5)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.5)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.5)" + fi - # Append warning flags from gcc 3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" + # gcc >= 4.6 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.6)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.6)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.6)" + fi - # Append warning flags from gcc 3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" + # gcc >= 4.7 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 7; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.7)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.7)" + fi - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" + # gcc >= 4.8 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 8; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-4.8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-4.8)" + fi - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" + # gcc >= 4.9 + if test $cc_vers_major -ge 5 -o $cc_vers_major -eq 4 -a $cc_vers_minor -ge 9; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 4.9)" + fi - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" + # gcc >= 5 + if test $cc_vers_major -ge 5; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 5)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-5)" + fi - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" + # gcc >= 6 + if test $cc_vers_major -ge 6; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 6)" + fi - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" + # gcc >= 7 + if test $cc_vers_major -ge 7; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 7)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-7)" + fi - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" + # gcc 8 + if test $cc_vers_major -ge 8; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 8)" + H5_ECXXFLAGS="$H5_ECXXFLAGS $(load_gnu_arguments error-8)" + DEVELOPER_WARNING_CXXFLAGS="$DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments developer-8)" + NO_DEVELOPER_WARNING_CXXFLAGS="$NO_DEVELOPER_WARNING_CXXFLAGS $(load_gcc_arguments no-developer-8)" + fi - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" + # gcc 9 + if test $cc_vers_major -ge 9; then + H5_CXXFLAGS="$H5_CXXFLAGS $(load_gnu_arguments 9)" + fi - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" + ################# + # Flags are set # + ################# + cxx_flags_set=yes +fi - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" +# Version-specific g++ flags - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" # Append more extra warning flags that only gcc 4.9+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdate-time -Wopenmp-simd" - ;; - - g++-4.8*) - # Append warning flags - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - - # Append more extra warning flags that only gcc 4.8+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsuggest-attribute=format" - ;; - - g++-4.7*) - # Append warning flags - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - - # Append more extra warning flags that only gcc 4.7+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstack-usage=8192 -Wvector-operation-performance -Wsuggest-attribute=pure -Wsuggest-attribute=noreturn" - ;; - - g++-4.6*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ knows about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-aliasing -Wstrict-overflow=5" - - # Append more extra warning flags that only gcc 4.6+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wdouble-promotion -Wsuggest-attribute=const -Wtrampolines" - ;; - - g++-4.5*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc4.0+ knows about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - - # Append more extra warning flags that only gcc 4.5+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-aliasing -Wstrict-overflow=5" - ;; - - g++-4.4*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wlarger-than=2048 -Wvla" - - # Append more extra warning flags that only gcc 4.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wsync-nand -Wframe-larger-than=16384 -Wpacked-bitfield-compat" - ;; - - g++-4.3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - - # Append more extra warning flags that only gcc 4.3+ know about - # - # Technically, variable-length arrays are part of the C99 standard, but - # we should approach them a bit cautiously... -QAK - H5_CXXFLAGS="$H5_CXXFLAGS -Wlogical-op -Wvla" - ;; - - g++-4.2*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - - # Append more extra warning flags that only gcc 4.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wstrict-overflow" - ;; - - g++-4.1.*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # Enable more format checking flags, beyond the basic -Wformat included - # in -Wall - H5_CXXFLAGS="$H5_CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - - # Append more extra warning flags that only gcc 4.1+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wunsafe-loop-optimizations -Wvolatile-register-var" - ;; - - g++-4.0*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append warning flags from gcc-3.4* case - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - - # Append more extra warning flags that only gcc 4.0+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wvariadic-macros -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wunused-macros" - ;; - - g++-3.4*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append warning flags from gcc-3.3* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - - # Append more extra warning flags that only gcc3.4+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Winvalid-pch" - - # Replace old -W flag with new -Wextra flag - H5_CXXFLAGS="`echo $H5_CXXFLAGS | sed -e 's/-W\ /-Wextra\ /g'`" - ;; - - g++-3.3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append warning flags from gcc-3.2* case - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - - # Append more extra warning flags that only gcc3.3+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wendif-labels" - ;; - - g++-3.2*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append warning flags from gcc-3* case - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - - # Append more extra warning flags that only gcc3.2+ know about - H5_CXXFLAGS="$H5_CXXFLAGS -Wmissing-noreturn -Wpacked -Wdisabled-optimization" - - # The "format=2" warning generates too many warnings about valid - # usage in the library. - #CXXFLAGS="$CXXFLAGS -Wformat=2" - - # The "unreachable code" flag generates many spurious C++ warnings. - # We'll disable it for now. - #H5_CXXFLAGS="$H5_CXXFLAGS -Wunreachable-code" - ;; - - g++-3*) - # Disable warnings about using 'long long' type - H5_CXXFLAGS="$H5_CXXFLAGS -Wno-long-long" - - # Append some extra warning flags that only gcc3+ know about - # (don't use -Wpadded flag for normal builds, many of the warnings its - # issuing can't be fixed and they are making it hard to detect other, - # more important warnings) - #H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute -Wpadded" - H5_CXXFLAGS="$H5_CXXFLAGS -Wfloat-equal -Wmissing-format-attribute" - ;; -esac + -Wopenmp-simd" # Clear cxx info if no flags set if test "X$cxx_flags_set" = "X"; then diff --git a/config/gnu-fflags b/config/gnu-fflags index 185a4c6..2859158 100644 --- a/config/gnu-fflags +++ b/config/gnu-fflags @@ -17,6 +17,20 @@ # if the compiler is not GNU; otherwise `f9x_flags_set' is set to `yes' # +# +# Prepend `$srcdir/config/gnu-warnings/` 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, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_gnu_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for GNU fortran # gfortran unless a compiler version is already known # @@ -95,8 +109,8 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # Symbols # ########### - SYMBOLS_FCFLAGS="-g" NO_SYMBOLS_FCFLAGS="-s" + SYMBOLS_FCFLAGS="-g" ############# # Profiling # @@ -125,8 +139,7 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # General # ########### - H5_FCFLAGS="$H5_FCFLAGS -pedantic -Wall -Wextra -Wunderflow -Wimplicit-interface -Wsurprising" - H5_FCFLAGS="$H5_FCFLAGS -Waliasing -Wcharacter-truncation" + H5_FCFLAGS="$H5_CFLAGS $(load_gnu_arguments gfort-general)" ############################# # Version-specific warnings # @@ -134,48 +147,45 @@ if test "X-gfortran" = "X-$f9x_vendor"; then # gfortran 4.3 (nothing new) - # gfortran 4.4 + # gfortran >= 4.4 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 4; then - H5_FCFLAGS="$H5_FCFLAGS -Warray-temporaries -Wintrinsics-std" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.4)" fi - # gfortran 4.5 + # gfortran >= 4.5 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 5; then - H5_FCFLAGS="$H5_FCFLAGS -Wimplicit-procedure" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.5)" fi # gfortran 4.6 (nothing new) - # gfortran 4.7 + # gfortran >= 4.7 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 7; then - H5_FCFLAGS="$H5_FCFLAGS -Wreal-q-constant -Wfunction-elimination" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.7)" fi - # gfortran 4.8 + # gfortran >= 4.8 if test $f9x_vers_major -ge 5 -o $f9x_vers_major -eq 4 -a $f9x_vers_minor -ge 8; then - H5_FCFLAGS="$H5_FCFLAGS -Wrealloc-lhs -Wrealloc-lhs-all" - # Turn off warnings for passing non-ANSI types to BIND(). - # We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. - H5_FCFLAGS="$H5_FCFLAGS -Wno-c-binding-type" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-4.8)" fi # gfortran 4.9 (nothing new) - # gfortran 5 + # gfortran >= 5 if test $f9x_vers_major -ge 5; then - H5_FCFLAGS="$H5_FCFLAGS -Wuse-without-only" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-5)" fi - # gfortran 6 + # gfortran >= 6 if test $f9x_vers_major -ge 6; then - H5_FCFLAGS="$H5_FCFLAGS -Winteger-division" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-6)" fi # gfortran 7 (nothing new) - # gfortran 8 + # gfortran >= 8 if test $f9x_vers_major -ge 8; then - H5_FCFLAGS="$H5_FCFLAGS -Wfrontend-loop-interchange" + H5_FCFLAGS="$H5_FCFLAGS $(load_gnu_arguments gfort-8)" fi # gfortran 9 (nothing new) diff --git a/config/gnu-flags b/config/gnu-flags index 11aaa71..c2904fe 100644 --- a/config/gnu-flags +++ b/config/gnu-flags @@ -18,20 +18,37 @@ # # -# Prepend `$srcdir/config/gnu-` to the filename suffix(es) given as +# 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-warnings/` 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, # and re-emit the file(s) thus filtered on the standard output stream. # -load_gcc_arguments() +load_gnu_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/gnu-${arg} + sed 's,#.*$,,' $srcdir/config/gnu-warnings/${arg} | demote_errors done) IFS=' ' echo "$*" } - # Get the compiler version in a way that works for gcc # unless a compiler version is already known # @@ -171,142 +188,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_gnu_arguments general)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_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_gnu_arguments no-developer-general) + DEVELOPER_WARNING_CFLAGS=$(load_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_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_gnu_arguments 5)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_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_gnu_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_gnu_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_gnu_arguments 8)" + H5_ECFLAGS="$H5_ECFLAGS $(load_gnu_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_gnu_arguments 9)" fi ################# @@ -320,3 +315,4 @@ if test "X$cc_flags_set" = "X"; then cc_vendor= cc_version= 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/intel-warnings-general b/config/gnu-warnings/cxx-general index f4ed24c..ee7ee22 100644 --- a/config/intel-warnings-general +++ b/config/gnu-warnings/cxx-general @@ -6,5 +6,14 @@ # 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. --Wall --Wcheck
\ No newline at end of file +-Wabi +-Wctor-dtor-privacy +-Weffc++ +##-Wendif-labels +-Wnon-virtual-dtor +-Wold-style-cast +-Woverloaded-virtual +-Wreorder +-Wsign-promo +##-Wunreachable-code +##-Wvariadic-macros 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/gfort-4.4 b/config/gnu-warnings/gfort-4.4 new file mode 100644 index 0000000..59fe9a2 --- /dev/null +++ b/config/gnu-warnings/gfort-4.4 @@ -0,0 +1,2 @@ +-Warray-temporaries +-Wintrinsics-std
\ No newline at end of file diff --git a/config/gnu-warnings/gfort-4.5 b/config/gnu-warnings/gfort-4.5 new file mode 100644 index 0000000..4490d4e --- /dev/null +++ b/config/gnu-warnings/gfort-4.5 @@ -0,0 +1 @@ +-Wimplicit-procedure diff --git a/config/gnu-warnings/gfort-4.7 b/config/gnu-warnings/gfort-4.7 new file mode 100644 index 0000000..a7532bb --- /dev/null +++ b/config/gnu-warnings/gfort-4.7 @@ -0,0 +1,2 @@ +-Wreal-q-constant +-Wfunction-elimination diff --git a/config/gnu-warnings/gfort-4.8 b/config/gnu-warnings/gfort-4.8 new file mode 100644 index 0000000..1b96a51 --- /dev/null +++ b/config/gnu-warnings/gfort-4.8 @@ -0,0 +1,5 @@ +-Wrealloc-lhs +-Wrealloc-lhs-all +# Turn off warnings for passing non-ANSI types to BIND(). +# We pass a lot of hid_t, etc. types so this generates a LOT of spurious warnings. +-Wno-c-binding-type diff --git a/config/gnu-warnings/gfort-5 b/config/gnu-warnings/gfort-5 new file mode 100644 index 0000000..c5d3850 --- /dev/null +++ b/config/gnu-warnings/gfort-5 @@ -0,0 +1 @@ +-Wuse-without-only diff --git a/config/gnu-warnings/gfort-6 b/config/gnu-warnings/gfort-6 new file mode 100644 index 0000000..f70466c --- /dev/null +++ b/config/gnu-warnings/gfort-6 @@ -0,0 +1 @@ +-Winteger-division diff --git a/config/gnu-warnings/gfort-8 b/config/gnu-warnings/gfort-8 new file mode 100644 index 0000000..5097365 --- /dev/null +++ b/config/gnu-warnings/gfort-8 @@ -0,0 +1 @@ +-Wfrontend-loop-interchange diff --git a/config/gnu-warnings/gfort-general b/config/gnu-warnings/gfort-general new file mode 100644 index 0000000..4028316 --- /dev/null +++ b/config/gnu-warnings/gfort-general @@ -0,0 +1,12 @@ +# Note that some of the flags listed here really should be developer +# flags (listed in separate files, gnu-warnings-developer*) 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. +-Waliasing +-Wall +-Wcharacter-truncation +-Wextra +-Wimplicit-interface +-Wsurprising +-Wunderflow +-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/intel-fflags b/config/intel-fflags index 8b1110e..ed7ee52 100644 --- a/config/intel-fflags +++ b/config/intel-fflags @@ -1,4 +1,4 @@ -# -*- shell-script -*- +# -*- shell-script -*- # # Copyright by The HDF Group. # Copyright by the Board of Trustees of the University of Illinois. @@ -17,6 +17,20 @@ # if the compiler is not Intel; otherwise `f9x_flags_set' is set to `yes' # +# +# Prepend `$srcdir/config/intel-warnings/` 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, +# and re-emit the file(s) thus filtered on the standard output stream. +# +load_intel_arguments() +{ + set -- $(for arg; do + sed 's,#.*$,,' $srcdir/config/intel-warnings/${arg} + done) + IFS=' ' echo "$*" +} + # Get the compiler version in a way that works for ifort # ifort unless a compiler version is already known # @@ -44,8 +58,8 @@ fi # Common Intel flags for various situations if test "X-ifort" = "X-$f9x_vendor"; then - # Insert section about version specific problems from gnu-flags here, if - # necessary. + # Insert section about version specific problems from compiler flags here, + # if necessary. arch= # Architecture-specific flags @@ -68,7 +82,8 @@ if test "X-ifort" = "X-$f9x_vendor"; then FC_BASENAME=ifort F9XSUFFIXFLAG="" FSEARCH_DIRS="" - H5_FCFLAGS="$H5_FCFLAGS" + H5_FCFLAGS="$H5_FCFLAGS -stand:f03 -free" + H5_FCFLAGS="$H5_FCFLAGS $(load_intel_arguments ifort-general)" # Production PROD_FCFLAGS= @@ -89,7 +104,9 @@ if test "X-ifort" = "X-$f9x_vendor"; then DEBUG_OPT_FCFLAGS= NO_OPT_FCFLAGS= - # Flags are set + ################# + # Flags are set # + ################# f9x_flags_set=yes fi diff --git a/config/intel-flags b/config/intel-flags index 6b4e406..100e68a 100644 --- a/config/intel-flags +++ b/config/intel-flags @@ -18,7 +18,7 @@ # # -# Prepend `$srcdir/config/intel-` to the filename suffix(es) given as +# Prepend `$srcdir/config/intel-warnings/` 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, # and re-emit the file(s) thus filtered on the standard output stream. @@ -26,7 +26,7 @@ load_intel_arguments() { set -- $(for arg; do - sed 's,#.*$,,' $srcdir/config/intel-${arg} + sed 's,#.*$,,' $srcdir/config/intel-warnings/${arg} done) IFS=' ' echo "$*" } @@ -81,7 +81,6 @@ if test "X-icc" = "X-$cc_vendor"; then # General # Default to C99 standard. H5_CFLAGS="$H5_CFLAGS $arch -std=c99" - H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments warnings-general)" # Production PROD_CFLAGS= @@ -103,16 +102,20 @@ if test "X-icc" = "X-$cc_vendor"; then DEBUG_OPT_CFLAGS="-O0" NO_OPT_CFLAGS="-O0" - # Flags are set - cc_flags_set=yes + ############ + # Warnings # + ############ -fi + ########### + # General # + ########### + + H5_CFLAGS="$H5_CFLAGS $(load_intel_arguments general)" + + ############################# + # Version-specific warnings # + ############################# -# Version specific ICC flags -# -# Please follow the pattern below by adding new versions at the top, copying -# the information from the previous version and adding modifications to that. -# The default at the bottom will apply if no earlier version matches. case "$cc_vendor-$cc_version" in icc-1[5-6]*) H5_CFLAGS="$H5_CFLAGS -Wcomment -Wdeprecated -Wextra-tokens -Wformat -Wformat-security -Wmain -Wmissing-declarations -Wmissing-prototypes -Wp64 -Wpointer-arith -Wreturn-type -Wshadow -Wstrict-prototypes -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-variable -Wwrite-strings" @@ -128,6 +131,13 @@ case "$cc_vendor-$cc_version" in ;; esac + ################# + # Flags are set # + ################# + cc_flags_set=yes + +fi + # Clear cc info if no flags set if test "X-$cc_flags_set" = "X-"; then cc_vendor= diff --git a/config/intel-warnings/general b/config/intel-warnings/general new file mode 100644 index 0000000..d0b2e25 --- /dev/null +++ b/config/intel-warnings/general @@ -0,0 +1,2 @@ +-Wall +-Wcheck
\ No newline at end of file diff --git a/config/intel-warnings/ifort-general b/config/intel-warnings/ifort-general new file mode 100644 index 0000000..a9da0e5 --- /dev/null +++ b/config/intel-warnings/ifort-general @@ -0,0 +1 @@ +-warn:all 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 c48e89c..e6d7535 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]) @@ -2860,7 +2864,7 @@ if test "X$MIRROR_VFD" = "Xyes"; then else AC_MSG_RESULT([no]) MIRROR_VFD=no - AC_MSG_ERROR([The Mirror VFD was cannot be built. + AC_MSG_ERROR([The Mirror VFD cannot be built. Missing any of: arpa/inet.h, netinet/in.h, netdb.h, sys/socket.h.]) fi diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index aa702ff..02a71c3 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -35,28 +35,22 @@ set (F2003_examples foreach (example ${examples}) add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f90_ex_${example} - PRIVATE - $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f90_ex_${example} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f90_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) target_include_directories (f90_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (f90_ex_${example} - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" ) + target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran @@ -65,12 +59,13 @@ foreach (example ${examples}) else () target_include_directories (f90_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (f90_ex_${example} - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" ) + target_link_libraries (f90_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran @@ -81,28 +76,22 @@ endforeach () foreach (example ${F2003_examples}) add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - target_compile_options(f03_ex_${example} - PRIVATE - $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f03_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f03_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f03_ex_${example} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f03_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f03_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT ONLY_SHARED_LIBS) target_include_directories (f03_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (f03_ex_${example} - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" ) + target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (f03_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 @@ -111,12 +100,13 @@ foreach (example ${F2003_examples}) else () target_include_directories (f03_ex_${example} PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (f03_ex_${example} - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" ) + target_link_libraries (f03_ex_${example} PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (f03_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 @@ -127,27 +117,26 @@ endforeach () if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) - target_compile_options(f90_ex_ph5example - PRIVATE - $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> - ) -# set_property(TARGET f90_ex_ph5example APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET f90_ex_ph5example APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) + target_compile_options(f90_ex_ph5example PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}>) +# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET f90_ex_ph5example APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET f90_ex_ph5example PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT ONLY_SHARED_LIBS) target_include_directories (f90_ex_ph5example PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + "${CMAKE_Fortran_MODULE_DIRECTORY}/static" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/static" + "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" ) target_link_libraries (f90_ex_ph5example PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} + ${HDF5_F90_LIB_TARGET} + ${HDF5_LIB_TARGET} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) set_target_properties (f90_ex_ph5example PROPERTIES @@ -158,11 +147,17 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) else () target_include_directories (f90_ex_ph5example PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + "${CMAKE_Fortran_MODULE_DIRECTORY}/shared" + "${HDF5_SRC_DIR}" + "${HDF5_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}" + "${HDF5_F90_BINARY_DIR}/shared" + "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" ) target_link_libraries (f90_ex_ph5example PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) set_target_properties (f90_ex_ph5example PROPERTIES diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index b5d1a60..bf2fd84 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -40,22 +40,14 @@ set (Fortran_COMPILER_ID CMAKE_Fortran_COMPILER_ID) #----------------------------------------------------------------------------- add_executable (H5_buildiface ${HDF5_F90_SRC_SOURCE_DIR}/H5_buildiface.F90) -target_include_directories (H5_buildiface - PRIVATE - "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}" -) +target_include_directories (H5_buildiface PRIVATE "${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}") #if (BUILD_SHARED_LIBS) -# target_compile_definitions(H5_buildiface -# PRIVATE -# $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/MT> -# ) +# target_compile_definitions(H5_buildiface PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/MT>) #endif () if(MSVC) set_property(TARGET H5_buildiface PROPERTY COMPILE_FLAGS "/MT") endif() -#set_property(TARGET H5_buildiface APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) +#set_property(TARGET H5_buildiface APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) if(MSVC) set_property(TARGET H5_buildiface PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE") endif() @@ -156,6 +148,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) + target_compile_options(${HDF5_F90_C_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC) target_link_libraries (${HDF5_F90_C_LIB_TARGET} PUBLIC ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") @@ -173,9 +166,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) - target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_F90_C_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_F90_C_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}") @@ -288,29 +280,23 @@ endif () if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SOURCES}) target_include_directories (${HDF5_F90_LIB_TARGET} - PRIVATE - "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" + PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" ) + target_compile_options(${HDF5_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIB_TARGET} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:HDF5F90_WINDOWS> $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_F90_LIB_TARGET} - PUBLIC - ${HDF5_F90_C_LIB_TARGET} + PUBLIC ${HDF5_F90_C_LIB_TARGET} PRIVATE ${LINK_Fortran_LIBS} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) -# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -328,36 +314,24 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) target_include_directories (${HDF5_F90_LIBSH_TARGET} - PRIVATE - "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" + PRIVATE "${HDF5_F90_SRC_SOURCE_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" ) + target_compile_options(${HDF5_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:BUILD_HDF5_DLL;HDF5F90_WINDOWS> $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_F90_LIBSH_TARGET} - PUBLIC - ${HDF5_F90_C_LIBSH_TARGET} - PRIVATE - ${LINK_Fortran_LIBS} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> + PUBLIC ${HDF5_F90_C_LIBSH_TARGET} + PRIVATE ${LINK_Fortran_LIBS} $<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_LIBRARIES}> ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL"> -# ) -# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def"> -# ) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL">) +# set_property(TARGET ${HDF5_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def">) if(MSVC) set_property(TARGET ${HDF5_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} /DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") endif() 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/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 5657323..ff7001b 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -13,8 +13,7 @@ target_include_directories (H5_test_buildiface ) #if (BUILD_SHARED_LIBS) # target_compile_definitions(H5_test_buildiface -# PRIVATE -# $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/MT> +# PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:/MT> # ) #endif () if(MSVC) @@ -49,6 +48,7 @@ if (NOT BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) + target_compile_options(${HDF5_F90_C_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIB_TARGET} STATIC) target_link_libraries (${HDF5_F90_C_TEST_LIB_TARGET} PRIVATE ${HDF5_F90_C_LIB_TARGET} @@ -65,9 +65,8 @@ else () PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) - target_compile_definitions(${HDF5_F90_C_TEST_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_F90_C_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_F90_C_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_F90_C_TEST_LIBSH_TARGET} PRIVATE ${HDF5_F90_C_LIBSH_TARGET} @@ -129,26 +128,18 @@ endif () if (NOT BUILD_SHARED_LIBS) add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC ${HDF5_F90_TF_SOURCES}) target_include_directories (${HDF5_F90_TEST_LIB_TARGET} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" ) + target_compile_options(${HDF5_F90_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_TEST_LIB_TARGET} PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:HDF5F90_WINDOWS> $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} - PUBLIC - ${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - ) -# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) + target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} PUBLIC ${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) +# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_F90_TEST_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -162,31 +153,20 @@ if (NOT BUILD_SHARED_LIBS) else () add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED ${HDF5_F90_TF_SOURCES_SHARED}) target_include_directories (${HDF5_F90_TEST_LIBSH_TARGET} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" + PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" ) + target_compile_options(${HDF5_F90_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_F90_TEST_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS> $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} - PUBLIC - ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL"> -# ) + target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL">) if(MSVC) set_property(TARGET ${HDF5_F90_TEST_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} -DLL") endif() @@ -223,26 +203,17 @@ add_executable (testhdf5_fortran ) target_compile_options(testhdf5_fortran PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET testhdf5_fortran APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET testhdf5_fortran APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET testhdf5_fortran APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET testhdf5_fortran APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET testhdf5_fortran PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (testhdf5_fortran - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (testhdf5_fortran - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (testhdf5_fortran PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -250,14 +221,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (testhdf5_fortran ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (testhdf5_fortran - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (testhdf5_fortran - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (testhdf5_fortran PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -277,26 +242,17 @@ add_executable (testhdf5_fortran_1_8 ) target_compile_options(testhdf5_fortran_1_8 PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET testhdf5_fortran_1_8 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET testhdf5_fortran_1_8 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (testhdf5_fortran_1_8 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (testhdf5_fortran_1_8 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran_1_8 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (testhdf5_fortran_1_8 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -304,14 +260,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (testhdf5_fortran_1_8 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (testhdf5_fortran_1_8 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (testhdf5_fortran_1_8 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (testhdf5_fortran_1_8 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (testhdf5_fortran_1_8 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -333,26 +283,17 @@ add_executable (fortranlib_test_F03 ) target_compile_options(fortranlib_test_F03 PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fortranlib_test_F03 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fortranlib_test_F03 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fortranlib_test_F03 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static" - ) - target_link_libraries (fortranlib_test_F03 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fortranlib_test_F03 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static") + target_link_libraries (fortranlib_test_F03 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -360,14 +301,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fortranlib_test_F03 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fortranlib_test_F03 - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared" - ) - target_link_libraries (fortranlib_test_F03 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fortranlib_test_F03 PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared") + target_link_libraries (fortranlib_test_F03 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fortranlib_test_F03 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -380,26 +315,17 @@ endif () add_executable (fflush1 fflush1.F90) target_compile_options(fflush1 PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fflush1 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fflush1 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fflush1 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fflush1 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fflush1 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fflush1 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (fflush1 - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fflush1 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (fflush1 PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -407,14 +333,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fflush1 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fflush1 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (fflush1 - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fflush1 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (fflush1 PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -427,26 +347,17 @@ endif () add_executable (fflush2 fflush2.F90) target_compile_options (fflush2 PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET fflush2 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET fflush2 APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET fflush2 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET fflush2 APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET fflush2 PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (fflush2 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (fflush2 - PRIVATE - ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fflush2 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (fflush2 PRIVATE ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -454,14 +365,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (fflush2 ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (fflush2 - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (fflush2 - PRIVATE - ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (fflush2 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (fflush2 PRIVATE ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -474,26 +379,17 @@ endif () add_executable (vol_connector vol_connector.F90) target_compile_options(vol_connector PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -#set_property(TARGET vol_connector APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET vol_connector APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET vol_connector APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET vol_connector APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET vol_connector PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (vol_connector - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/static - ) - target_link_libraries (vol_connector - PRIVATE - ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (vol_connector PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + target_link_libraries (vol_connector PRIVATE ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran @@ -501,14 +397,8 @@ if (NOT BUILD_SHARED_LIBS) ) add_dependencies (vol_connector ${HDF5_F90_TEST_LIB_TARGET}) else () - target_include_directories (vol_connector - PRIVATE - ${CMAKE_Fortran_MODULE_DIRECTORY}/shared - ) - target_link_libraries (vol_connector - PRIVATE - ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib> - ) + target_include_directories (vol_connector PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + target_link_libraries (vol_connector PRIVATE ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} $<$<PLATFORM_ID:Windows>:ws2_32.lib>) set_target_properties (vol_connector PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt index 5c80fd6..12489528 100644 --- a/fortran/testpar/CMakeLists.txt +++ b/fortran/testpar/CMakeLists.txt @@ -22,11 +22,11 @@ add_executable (parallel_test mdset.f90 ) target_include_directories (parallel_test - PRIVATE - ${TESTPAR_INCLUDES} + PRIVATE ${TESTPAR_INCLUDES} ) target_compile_options(parallel_test PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) if (NOT BUILD_SHARED_LIBS) @@ -53,12 +53,8 @@ else () ) endif () -#set_property(TARGET parallel_test APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -#) -#set_property(TARGET parallel_test APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -#) +#set_property(TARGET parallel_test APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +#set_property(TARGET parallel_test APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET parallel_test PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 866f372..fbabc86 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -14,6 +14,7 @@ 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,9 +29,8 @@ 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_definitions(${HDF5_HL_CPP_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + 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") TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_CPP_LIBSH_TARGET} PUBLIC ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIBSH_TARGET}") diff --git a/hl/c++/test/CMakeLists.txt b/hl/c++/test/CMakeLists.txt index 9bf32ef..5c224a8 100644 --- a/hl/c++/test/CMakeLists.txt +++ b/hl/c++/test/CMakeLists.txt @@ -2,6 +2,7 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_HL_CPP_TEST CXX) add_executable (hl_ptableTest ${HDF5_HL_CPP_TEST_SOURCE_DIR}/ptableTest.cpp) +target_compile_options(hl_ptableTest PRIVATE "${HDF5_CMAKE_CXX_FLAGS}") target_include_directories (hl_ptableTest PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_ptableTest STATIC) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index 265d8db..e6411c1 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -12,38 +12,22 @@ foreach (example ${examples}) PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET hl_f90_ex_${example} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET hl_f90_ex_${example} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (hl_f90_ex_${example} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_ex_${example} - PRIVATE - ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} - ) + target_include_directories (hl_f90_ex_${example} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_ex_${example} PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/hl/fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) else () - target_include_directories (hl_f90_ex_${example} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_ex_${example} - PRIVATE - ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} - ) + target_include_directories (hl_f90_ex_${example} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_ex_${example} PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/hl/fortran diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index d4979ba..71b9380 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -62,6 +62,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) + target_compile_options(${HDF5_HL_F90_C_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} STATIC) target_link_libraries (${HDF5_HL_F90_C_LIB_TARGET} PUBLIC ${HDF5_F90_C_LIB_TARGET} ${HDF5_HL_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}") @@ -78,9 +79,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_F90_BINARY_DIR}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) - target_compile_definitions(${HDF5_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_HL_F90_C_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_HL_F90_C_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_F90_C_LIBSH_TARGET} PUBLIC ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_HL_LIBSH_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIBSH_TARGET}") @@ -161,27 +161,17 @@ endif () if (NOT ONLY_SHARED_LIBS) add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES}) target_include_directories (${HDF5_HL_F90_LIB_TARGET} - PRIVATE - "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" + PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/static;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/static>" ) + target_compile_options(${HDF5_HL_F90_LIB_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIB_TARGET} - PUBLIC - $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:HDF5F90_WINDOWS> - PRIVATE - $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> + PUBLIC $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:HDF5F90_WINDOWS> + PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) - target_link_libraries (${HDF5_HL_F90_LIB_TARGET} - PUBLIC - ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET} - ) -# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) + target_link_libraries (${HDF5_HL_F90_LIB_TARGET} PUBLIC ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) +# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET ${HDF5_HL_F90_LIB_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() @@ -198,36 +188,24 @@ endif () if (BUILD_SHARED_LIBS) add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) target_include_directories (${HDF5_HL_F90_LIBSH_TARGET} - PRIVATE - "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" - INTERFACE - "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" + PRIVATE "${HDF5_F90_BINARY_DIR};${CMAKE_Fortran_MODULE_DIRECTORY}/shared;$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_Fortran_INCLUDE_DIRS}>" + INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/shared>" ) + target_compile_options(${HDF5_HL_F90_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_Fortran_FLAGS}") target_compile_definitions(${HDF5_HL_F90_LIBSH_TARGET} - PUBLIC - "H5_BUILT_AS_DYNAMIC_LIB" + PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" PRIVATE $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:BUILD_HDF5_HL_DLL;HDF5F90_WINDOWS> $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) target_link_libraries (${HDF5_HL_F90_LIBSH_TARGET} - PUBLIC - ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} - PRIVATE - ${LINK_Fortran_LIBS} + PUBLIC ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} + PRIVATE ${LINK_Fortran_LIBS} ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL"> -# ) -# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def"> -# ) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DLL">) +# set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def">) if(MSVC) set_property(TARGET ${HDF5_HL_F90_LIBSH_TARGET} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS} -DLL -DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def") endif() diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt index 269cefb..e2872ac 100644 --- a/hl/fortran/test/CMakeLists.txt +++ b/hl/fortran/test/CMakeLists.txt @@ -15,40 +15,25 @@ macro (ADD_H5_FORTRAN_EXE file) add_executable (hl_f90_${file} ${file}.F90) target_compile_options(hl_f90_${file} PRIVATE + "${HDF5_CMAKE_Fortran_FLAGS}" $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_COMPILE_FLAGS}> ) -# set_property(TARGET hl_f90_${file} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE"> -# ) -# set_property(TARGET hl_f90_${file} APPEND PROPERTY -# LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}> -# ) +# set_property(TARGET hl_f90_${file} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:"-SUBSYSTEM:CONSOLE">) +# set_property(TARGET hl_f90_${file} APPEND PROPERTY LINK_FLAGS $<$<STREQUAL:"x${CMAKE_Fortran_SIMULATE_ID}","xMSVC">:${WIN_LINK_FLAGS}>) if(MSVC) set_property(TARGET hl_f90_${file} PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE ${WIN_LINK_FLAGS}") endif() if (NOT BUILD_SHARED_LIBS) - target_include_directories (hl_f90_${file} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_${file} - PRIVATE - ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} - ) + target_include_directories (hl_f90_${file} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/static;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_${file} PRIVATE ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET}) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/hl/fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) else () - target_include_directories (hl_f90_${file} - PRIVATE - "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src" - ) - target_link_libraries (hl_f90_${file} - PRIVATE - ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET} - ) + target_include_directories (hl_f90_${file} PRIVATE "${CMAKE_Fortran_MODULE_DIRECTORY}/shared;${HDF5_F90_BINARY_DIR};${HDF5_F90_SRC_DIR}/src") + target_link_libraries (hl_f90_${file} PRIVATE ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_TEST_LIBSH_TARGET}) set_target_properties (hl_f90_${file} PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/hl/fortran diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index 55d84c7..c4ddf19 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -38,6 +38,7 @@ 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,9 +53,8 @@ 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_definitions(${HDF5_HL_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + 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") TARGET_C_PROPERTIES (${HDF5_HL_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_HL_LIBSH_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) H5_SET_LIB_OPTIONS (${HDF5_HL_LIBSH_TARGET} ${HDF5_HL_LIB_NAME} SHARED "HL") diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index 43fc312..6349bb3 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -19,6 +19,7 @@ configure_file (${HDF5_HL_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ON # -------------------------------------------------------------------- macro (HL_ADD_EXE hl_name) add_executable (hl_${hl_name} ${hl_name}.c) + target_compile_options(hl_${hl_name} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_${hl_name} PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_${hl_name} STATIC) @@ -49,6 +50,7 @@ HL_ADD_EXE (test_h5do_compat) # test_packet has two source files add_executable (hl_test_packet test_packet.c test_packet_vlen.c) +target_compile_options(hl_test_packet PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_test_packet PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (hl_test_packet STATIC) @@ -73,6 +75,7 @@ set_target_properties (hl_test_packet PROPERTIES FOLDER test/hl) # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (hl_gen_test_ds gen_test_ds.c) + target_compile_options(hl_gen_test_ds PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_gen_test_ds PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ds STATIC) target_link_libraries (hl_gen_test_ds PRIVATE @@ -83,6 +86,7 @@ if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen) add_executable (hl_gen_test_ld gen_test_ld.c) + target_compile_options(hl_gen_test_ld PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_gen_test_ld PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (hl_gen_test_ld STATIC) target_link_libraries (hl_gen_test_ld PRIVATE diff --git a/hl/tools/gif2h5/CMakeLists.txt b/hl/tools/gif2h5/CMakeLists.txt index cc2ba68..0b895a3 100644 --- a/hl/tools/gif2h5/CMakeLists.txt +++ b/hl/tools/gif2h5/CMakeLists.txt @@ -16,6 +16,7 @@ set (GIF2H5_SOURCES #-- Add gif2hdf5 program if (NOT ONLY_SHARED_LIBS) add_executable (gif2h5 ${GIF2H5_SOURCES}) + target_compile_options(gif2h5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (gif2h5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (gif2h5 STATIC) target_link_libraries (gif2h5 PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -28,6 +29,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (gif2h5-shared ${GIF2H5_SOURCES}) + target_compile_options(gif2h5-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (gif2h5-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (gif2h5-shared SHARED) target_link_libraries (gif2h5-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) @@ -45,6 +47,7 @@ set (hdf2gif_SOURCES ) if (NOT ONLY_SHARED_LIBS) add_executable (h52gif ${hdf2gif_SOURCES}) + target_compile_options(h52gif PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h52gif PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h52gif STATIC) target_link_libraries (h52gif PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -57,6 +60,7 @@ endif () if (BUILD_SHARED_LIBS) add_executable (h52gif-shared ${hdf2gif_SOURCES}) + target_compile_options(h52gif-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h52gif-shared PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h52gif-shared SHARED) target_link_libraries (h52gif-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} PRIVATE ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) diff --git a/hl/tools/h5watch/CMakeLists.txt b/hl/tools/h5watch/CMakeLists.txt index 9329c97..c5ad976 100644 --- a/hl/tools/h5watch/CMakeLists.txt +++ b/hl/tools/h5watch/CMakeLists.txt @@ -11,6 +11,7 @@ set (H5WATCH_SOURCES #-- Add h5watch program if (NOT ONLY_SHARED_LIBS) add_executable (h5watch ${H5WATCH_SOURCES}) + target_compile_options(h5watch PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watch PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5watch STATIC) target_link_libraries (h5watch PRIVATE ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) @@ -19,6 +20,7 @@ if (NOT ONLY_SHARED_LIBS) endif () if (BUILD_SHARED_LIBS) add_executable (h5watch-shared ${H5WATCH_SOURCES}) + target_compile_options(h5watch-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watch-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5watch-shared SHARED) target_link_libraries (h5watch-shared PRIVATE ${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${HDF5_TOOLS_LIBSH_TARGET}) @@ -32,6 +34,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/swmr_check_compat_vfd.c ) add_executable (hl_swmr_check_compat_vfd ${hl_swmr_check_compat_vfd_SOURCES}) + target_compile_options(hl_swmr_check_compat_vfd PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (hl_swmr_check_compat_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (hl_swmr_check_compat_vfd STATIC) @@ -47,6 +50,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/extend_dset.c ) add_executable (extend_dset ${extend_dset_SOURCES}) + target_compile_options(extend_dset PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (extend_dset PRIVATE "${HDF5_HL_SRC_DIR}/test;${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (extend_dset STATIC) @@ -58,6 +62,7 @@ if (BUILD_TESTING AND HDF5_TEST_SWMR AND HDF5_TEST_SERIAL) set_target_properties (extend_dset PROPERTIES FOLDER tools/hl) add_executable (h5watchgentest ${HDF5_HL_TOOLS_H5WATCH_SOURCE_DIR}/h5watchgentest.c) + target_compile_options(h5watchgentest PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (h5watchgentest PRIVATE "${HDF5_HL_SRC_DIR}/src;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5watchgentest STATIC) 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..3f71122 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -79,6 +79,7 @@ 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 8931b0f..6c43908 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -48,6 +48,34 @@ 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, C++ and gfortran 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. + Intel C, Fortran warnings flags were moved to files in a config sub-folder + named intel-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. + + In addition, CMake no longer applies these warnings for examples. + + (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 @@ -433,6 +461,17 @@ New Features (ADB - 2018/09/18, HDFFV-10332) + - Fix shutdown failure when using H5VLregister_connector_by_name/value + + When using H5VLregister_connector_by_name/value to dynamically load a + VOL connector plugin, the library can experience segmentation faults + when the library is closed. This is due to the library unloading + the plugin interface before the virtual object layer. Then, when the + VOL shutdown occurs, it will attempt to close the VOL connector, + however this will fail since the plugin will already have been unloaded. + + (DER - 2020/03/18, HDFFV-11057) + Parallel Library: ----------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6678aaf..c0915c8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1141,6 +1141,7 @@ 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} @@ -1177,6 +1178,7 @@ 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" @@ -355,7 +355,9 @@ H5_term_library(void) pending += DOWN(Z); pending += DOWN(FD); pending += DOWN(VL); - pending += DOWN(PL); + /* Don't shut down the plugin code until all "pluggable" interfaces (Z, FD, PL) are shut down */ + if(pending == 0) + pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ if(pending == 0) pending += DOWN(E); @@ -556,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 1624f7b..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. @@ -1418,8 +1421,18 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTRESET, NULL, "unable to reset external file list info") if(new_dset->shared->space && H5S_close(new_dset->shared->space) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataspace") - if(new_dset->shared->type && H5I_dec_ref(new_dset->shared->type_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release datatype") + + if(new_dset->shared->type) { + if(new_dset->shared->type_id > 0) { + if(H5I_dec_ref(new_dset->shared->type_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + } /* end if */ + else { + if(H5T_close_real(new_dset->shared->type) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release datatype") + } /* end else */ + } /* end if */ + if(H5F_addr_defined(new_dset->oloc.addr)) { if(H5O_dec_rc_by_loc(&(new_dset->oloc)) < 0) HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") @@ -2550,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 @@ -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 @@ -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/H5Rint.c b/src/H5Rint.c index 1df8a20..30f3dbb 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -1768,6 +1768,7 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, H5O_token_t token = { 0 }; size_t data_size; const uint8_t *p; + H5S_t *space = NULL; herr_t ret_value = SUCCEED; FUNC_ENTER_PACKAGE @@ -1788,7 +1789,6 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, if(space_ptr) { H5O_loc_t oloc; /* Object location */ - H5S_t *space = NULL; /* Initialize the object location */ H5O_loc_reset(&oloc); @@ -1812,6 +1812,12 @@ H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, done: H5MM_free(data); + + if(ret_value < 0) { + if(space && H5S_close(space) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + } + FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__decode_token_region_compat() */ diff --git a/src/H5Sall.c b/src/H5Sall.c index 4a4245d..77fb582 100644 --- a/src/H5Sall.c +++ b/src/H5Sall.c @@ -690,6 +690,9 @@ H5S__all_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); + if(version < H5S_ALL_VERSION_1 || version > H5S_ALL_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for all selection") + /* Skip over the remainder of the header */ *p += 8; diff --git a/src/H5Snone.c b/src/H5Snone.c index 0949b2a..630d1d5 100644 --- a/src/H5Snone.c +++ b/src/H5Snone.c @@ -648,6 +648,9 @@ H5S__none_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(*p, version); + if(version < H5S_NONE_VERSION_1 || version > H5S_NONE_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for none selection") + /* Skip over the remainder of the header */ *p += 8; diff --git a/src/H5Spkg.h b/src/H5Spkg.h index e139bce..da2dd4a 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -47,14 +47,17 @@ #define H5S_HYPER_VERSION_LATEST H5S_HYPER_VERSION_3 /* Versions for H5S_SEL_POINTS selection info */ -#define H5S_POINT_VERSION_1 1 -#define H5S_POINT_VERSION_2 2 +#define H5S_POINT_VERSION_1 1 +#define H5S_POINT_VERSION_2 2 +#define H5S_POINT_VERSION_LATEST H5S_POINT_VERSION_2 /* Versions for H5S_SEL_NONE selection info */ -#define H5S_NONE_VERSION_1 1 +#define H5S_NONE_VERSION_1 1 +#define H5S_NONE_VERSION_LATEST H5S_NONE_VERSION_1 /* Versions for H5S_SEL_ALL selection info */ -#define H5S_ALL_VERSION_1 1 +#define H5S_ALL_VERSION_1 1 +#define H5S_ALL_VERSION_LATEST H5S_ALL_VERSION_1 /* Encoded size of selection info for H5S_SEL_POINTS/H5S_SEL_HYPER */ #define H5S_SELECT_INFO_ENC_SIZE_2 0x02 /* 2 bytes: 16 bits */ diff --git a/src/H5Spoint.c b/src/H5Spoint.c index 721211e..6948125 100644 --- a/src/H5Spoint.c +++ b/src/H5Spoint.c @@ -1413,6 +1413,9 @@ H5S__point_deserialize(H5S_t **space, const uint8_t **p) /* Decode version */ UINT32DECODE(pp, version); + if(version < H5S_POINT_VERSION_1 || version > H5S_POINT_VERSION_LATEST) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "bad version number for point selection") + if(version >= (uint32_t)H5S_POINT_VERSION_2) /* Decode size of point info */ enc_size = *(pp)++; @@ -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 */ @@ -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/H5VLconnector.h b/src/H5VLconnector.h index 39d9b14..7951a32 100644 --- a/src/H5VLconnector.h +++ b/src/H5VLconnector.h @@ -194,7 +194,7 @@ typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_FILE, /* object file */ H5VL_OBJECT_GET_NAME, /* object name */ H5VL_OBJECT_GET_TYPE, /* object type */ - H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name)3 */ + H5VL_OBJECT_GET_INFO /* H5Oget_info(_by_idx|name) */ } H5VL_object_get_t; /* types for object SPECIFIC callback */ diff --git a/src/H5VLint.c b/src/H5VLint.c index 6572faa..861629f 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -273,7 +273,7 @@ H5VL_term_package(void) else { if(H5I_nmembers(H5I_VOL) > 0) { /* Unregister all VOL connectors */ - (void)H5I_clear_type(H5I_VOL, FALSE, FALSE); + (void)H5I_clear_type(H5I_VOL, TRUE, FALSE); n++; } /* end if */ else { diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c index 8b3dc62..2cf470e 100644 --- a/src/H5VLpassthru.c +++ b/src/H5VLpassthru.c @@ -1591,6 +1591,10 @@ H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); @@ -1645,6 +1649,10 @@ H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return NULL; + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); @@ -1785,6 +1793,10 @@ H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, /* Get copy of our VOL info from FAPL */ H5Pget_vol_info(fapl_id, (void **)&info); + /* Make sure we have info about the underlying VOL to be used */ + if (!info) + return (-1); + /* Copy the FAPL */ under_fapl_id = H5Pcopy(fapl_id); 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..f9f96e2 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); @@ -249,7 +249,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -263,7 +263,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -282,7 +282,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -298,7 +298,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -336,7 +336,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -362,7 +362,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -396,7 +396,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'F': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -430,7 +430,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -460,7 +460,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -498,7 +498,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -544,7 +544,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -586,7 +586,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -633,7 +633,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -663,7 +663,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -697,7 +697,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -723,7 +723,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -759,7 +759,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -778,7 +778,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -804,21 +804,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); - HDfprintf(out, "0x%lx", (unsigned long)error); + HDfprintf(out, "0x%p", error); } /* end else */ break; case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -849,7 +849,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -883,7 +883,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -917,7 +917,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -952,7 +952,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1003,7 +1003,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1029,7 +1029,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1038,7 +1038,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1088,7 +1088,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1136,14 +1136,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); - HDfprintf(out, "0x%lx", (unsigned long)statbuf); + HDfprintf(out, "0x%p", statbuf); } break; #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -1157,7 +1157,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hsize_t *p = (hsize_t *)vp; @@ -1191,7 +1191,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { hssize_t *p = (hssize_t *)vp; @@ -1221,7 +1221,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1417,7 +1417,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1451,7 +1451,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1489,7 +1489,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { int *p = (int*)vp; @@ -1513,7 +1513,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1603,7 +1603,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned *p = (unsigned*)vp; @@ -1633,7 +1633,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1651,7 +1651,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1697,7 +1697,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1713,7 +1713,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1729,7 +1729,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1788,7 +1788,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1804,7 +1804,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1852,7 +1852,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1879,7 +1879,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1893,7 +1893,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1907,7 +1907,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1921,7 +1921,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -1975,7 +1975,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2009,7 +2009,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2067,7 +2067,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2115,7 +2115,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2131,7 +2131,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2178,7 +2178,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2208,7 +2208,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2238,7 +2238,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2272,7 +2272,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2314,7 +2314,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'p': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2352,7 +2352,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2386,7 +2386,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2456,7 +2456,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2512,7 +2512,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2533,7 +2533,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long *p = (unsigned long *)vp; @@ -2557,7 +2557,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { unsigned long long *p = (unsigned long long *)vp; @@ -2589,7 +2589,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2625,7 +2625,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'A': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2643,7 +2643,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'b': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2673,7 +2673,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'B': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2703,7 +2703,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'C': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2720,7 +2720,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2756,7 +2756,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'd': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2783,7 +2783,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'e': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2807,7 +2807,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2831,7 +2831,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'g': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2873,7 +2873,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'h': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2912,7 +2912,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'i': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2936,7 +2936,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'j': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2960,7 +2960,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'k': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -2987,7 +2987,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'l': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3014,7 +3014,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'L': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3038,7 +3038,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'm': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3065,7 +3065,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'n': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3095,7 +3095,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'o': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3131,7 +3131,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'r': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3158,7 +3158,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3181,7 +3181,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'S': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3238,7 +3238,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 't': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3286,7 +3286,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'u': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3304,7 +3304,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'v': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3409,7 +3409,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'w': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3435,7 +3435,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3453,7 +3453,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'y': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3489,7 +3489,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) - HDfprintf (out, "0x%lx", (unsigned long)vp); + HDfprintf (out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3513,14 +3513,14 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'x': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { void **p = (void**)vp; HDfprintf(out, " {"); for(i = 0; i < asize[asize_idx]; i++) { if(p[i]) - HDfprintf(out, "%s0x%lx", (i ? ", " : ""), (unsigned long)(p[i])); + HDfprintf(out, "%s0x%p", (i ? ", " : ""), p[i]); else HDfprintf(out, "%sNULL", (i ? ", " : "")); } /* end for */ @@ -3534,7 +3534,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) vp = HDva_arg (ap, void *); if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end else */ @@ -3543,7 +3543,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'z': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { size_t *p = (size_t *)vp; @@ -3569,7 +3569,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'a': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3599,21 +3599,21 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'c': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ else { H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); - HDfprintf(out, "0x%lx", (unsigned long)filter); + HDfprintf(out, "0x%p", filter); } /* end else */ break; case 'e': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3632,7 +3632,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 'f': if(ptr) { if(vp) - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); else HDfprintf(out, "NULL"); } /* end if */ @@ -3649,7 +3649,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case 's': if(ptr) { if(vp) { - HDfprintf(out, "0x%lx", (unsigned long)vp); + HDfprintf(out, "0x%p", vp); if(asize_idx >= 0 && asize[asize_idx] >= 0) { ssize_t *p = (ssize_t *)vp; diff --git a/src/libhdf5.settings.in b/src/libhdf5.settings.in index df7ddf2..192fc6f 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/CMakeLists.txt b/test/CMakeLists.txt index cba1d3a..e3bfeb3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,6 +32,7 @@ if (NOT ONLY_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) + target_compile_options(${HDF5_TEST_LIB_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (${HDF5_TEST_LIB_TARGET} STATIC) target_link_libraries (${HDF5_TEST_LIB_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIB_TARGET} @@ -50,9 +51,8 @@ if (BUILD_SHARED_LIBS) PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" INTERFACE "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>" ) - target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} - PUBLIC "H5_BUILT_AS_DYNAMIC_LIB" - ) + target_compile_options(${HDF5_TEST_LIBSH_TARGET} PRIVATE "${HDF5_CMAKE_C_FLAGS}") + target_compile_definitions(${HDF5_TEST_LIBSH_TARGET} PUBLIC "H5_BUILT_AS_DYNAMIC_LIB") TARGET_C_PROPERTIES (${HDF5_TEST_LIBSH_TARGET} SHARED) target_link_libraries (${HDF5_TEST_LIBSH_TARGET} PUBLIC ${LINK_LIBS} ${HDF5_LIBSH_TARGET} @@ -293,13 +293,14 @@ set (H5_TESTS cache_logging cork swmr - thread_id + thread_id # special link vol ) macro (ADD_H5_EXE file) add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (${file} STATIC) target_link_libraries (${file} PRIVATE ${HDF5_TEST_LIB_TARGET}) @@ -316,6 +317,7 @@ set (H5_TESTS_MULTIPLE testhdf5 cache_image ttsafe + thread_id # special link mirror_vfd ) # Only build single source tests here @@ -331,6 +333,7 @@ endforeach () ######### Also special handling of link libs ############# #-- Adding test for chunk_info add_executable (chunk_info ${HDF5_TEST_SOURCE_DIR}/chunk_info.c) +target_compile_options(chunk_info PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (chunk_info PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (chunk_info STATIC) @@ -343,6 +346,7 @@ set_target_properties (chunk_info PROPERTIES FOLDER test) #-- Adding test for direct_chunk add_executable (direct_chunk ${HDF5_TEST_SOURCE_DIR}/direct_chunk.c) +target_compile_options(direct_chunk PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (direct_chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};${HDF5_TEST_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (direct_chunk STATIC) @@ -357,6 +361,7 @@ set_target_properties (direct_chunk PROPERTIES FOLDER test) ######### Special handling for multiple sources ############# #-- Adding test for testhdf5 add_executable (testhdf5 ${testhdf5_SOURCES}) +target_compile_options(testhdf5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (testhdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (testhdf5 STATIC) @@ -369,6 +374,7 @@ set_target_properties (testhdf5 PROPERTIES FOLDER test) #-- Adding test for cache_image add_executable (cache_image ${cache_image_SOURCES}) +target_compile_options(cache_image PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (cache_image PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (cache_image STATIC) @@ -381,6 +387,7 @@ set_target_properties (cache_image PROPERTIES FOLDER test) #-- Adding test for ttsafe add_executable (ttsafe ${ttsafe_SOURCES}) +target_compile_options(ttsafe PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (ttsafe PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (ttsafe STATIC) @@ -396,6 +403,25 @@ else () endif () set_target_properties (ttsafe PROPERTIES FOLDER test) +######### Special handling for extra link lib of threads ############# +#-- Adding test for thread_id +add_executable (thread_id ${HDF5_TEST_SOURCE_DIR}/thread_id.c) +target_compile_options(thread_id PRIVATE "${HDF5_CMAKE_C_FLAGS}") +target_include_directories (thread_id PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") +if (NOT BUILD_SHARED_LIBS) + TARGET_C_PROPERTIES (thread_id STATIC) + target_link_libraries (thread_id PRIVATE ${HDF5_TEST_LIB_TARGET}) + if (NOT WIN32) + target_link_libraries (thread_id + PRIVATE $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads> + ) + endif () +else () + TARGET_C_PROPERTIES (thread_id SHARED) + target_link_libraries (thread_id PRIVATE ${HDF5_TEST_LIBSH_TARGET} $<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:Threads::Threads>) +endif () +set_target_properties (thread_id PROPERTIES FOLDER test) + #-- Adding test for mirror_vfd add_executable (mirror_vfd ${mirror_vfd_SOURCES}) target_include_directories (mirror_vfd PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") @@ -476,6 +502,7 @@ endforeach () # This has to be copied to the test directory for execve() to find it # and it can't be renamed (i.e., no <foo>-shared). add_executable (accum_swmr_reader ${HDF5_TEST_SOURCE_DIR}/accum_swmr_reader.c) +target_compile_options(accum_swmr_reader PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (accum_swmr_reader PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (accum_swmr_reader STATIC) @@ -511,6 +538,7 @@ endif () ############################################################################## set (use_append_chunk_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_chunk.c ${HDF5_TEST_SOURCE_DIR}/use_common.c) add_executable (use_append_chunk ${use_append_chunk_SOURCES}) +target_compile_options(use_append_chunk PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_append_chunk PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_append_chunk STATIC) @@ -523,6 +551,7 @@ set_target_properties (use_append_chunk PROPERTIES FOLDER test) set (use_append_mchunks_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_append_mchunks.c ${HDF5_TEST_SOURCE_DIR}/use_common.c) add_executable (use_append_mchunks ${use_append_mchunks_SOURCES}) +target_compile_options(use_append_mchunks PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_append_mchunks PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_append_mchunks STATIC) @@ -535,6 +564,7 @@ set_target_properties (use_append_mchunks PROPERTIES FOLDER test) set (use_disable_mdc_flushes_SOURCES ${HDF5_TEST_SOURCE_DIR}/use_disable_mdc_flushes.c) add_executable (use_disable_mdc_flushes ${use_disable_mdc_flushes_SOURCES}) +target_compile_options(use_disable_mdc_flushes PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (use_disable_mdc_flushes PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (use_disable_mdc_flushes 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(®_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(®_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/test/trefer.c b/test/trefer.c index 32caf5e..d399fef 100644 --- a/test/trefer.c +++ b/test/trefer.c @@ -631,173 +631,179 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dcreate2"); + H5E_BEGIN_TRY { + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + + if(dset1 < 0) { + VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); - /* Create references */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Select 6x6 hyperslab for first reference */ - start[0] = 2; start[1] = 2; - stride[0] = 1; stride[1] = 1; - count[0] = 1; count[1] = 1; - block[0] = 6; block[1] = 6; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); - ret = (int)H5Sget_select_npoints(sid2); - VERIFY(ret, 36, "H5Sget_select_npoints"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - /* Store first dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[0]); - CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + } else { - /* Select sequence of ten points for second reference */ - coord1[0][0] = 6; coord1[0][1] = 9; - coord1[1][0] = 2; coord1[1][1] = 2; - coord1[2][0] = 8; coord1[2][1] = 4; - coord1[3][0] = 1; coord1[3][1] = 6; - coord1[4][0] = 2; coord1[4][1] = 8; - coord1[5][0] = 3; coord1[5][1] = 2; - coord1[6][0] = 0; coord1[6][1] = 4; - coord1[7][0] = 9; coord1[7][1] = 0; - coord1[8][0] = 7; coord1[8][1] = 1; - coord1[9][0] = 3; coord1[9][1] = 3; - ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); - CHECK(ret, FAIL, "H5Sselect_elements"); + CHECK(dset1, H5I_INVALID_HID, "H5Dcreate2"); - ret = (int)H5Sget_select_npoints(sid2); - VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); + /* Create references */ - /* Store second dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[1]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Select 6x6 hyperslab for first reference */ + start[0] = 2; start[1] = 2; + stride[0] = 1; stride[1] = 1; + count[0] = 1; count[1] = 1; + block[0] = 6; block[1] = 6; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Select unlimited hyperslab for third reference */ - start[0] = 1; - start[1] = 8; - stride[0] = 4; - stride[1] = 1; - count[0] = H5S_UNLIMITED; - count[1] = 1; - block[0] = 2; - block[1] = 2; - ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + ret = (int)H5Sget_select_npoints(sid2); + VERIFY(ret, 36, "H5Sget_select_npoints"); - hssize_ret = H5Sget_select_npoints(sid2); - VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); + /* Store first dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[0]); + CHECK(ret, FAIL, "H5Rcreate_region"); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Store third dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[2]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Select sequence of ten points for second reference */ + coord1[0][0] = 6; coord1[0][1] = 9; + coord1[1][0] = 2; coord1[1][1] = 2; + coord1[2][0] = 8; coord1[2][1] = 4; + coord1[3][0] = 1; coord1[3][1] = 6; + coord1[4][0] = 2; coord1[4][1] = 8; + coord1[5][0] = 3; coord1[5][1] = 2; + coord1[6][0] = 0; coord1[6][1] = 4; + coord1[7][0] = 9; coord1[7][1] = 0; + coord1[8][0] = 7; coord1[8][1] = 1; + coord1[9][0] = 3; coord1[9][1] = 3; + ret = H5Sselect_elements(sid2, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + CHECK(ret, FAIL, "H5Sselect_elements"); - ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = (int)H5Sget_select_npoints(sid2); + VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); - /* Store fourth dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[3]); - CHECK(ret, FAIL, "H5Rcreate_region"); + /* Store second dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[1]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Write selection to disk */ - H5E_BEGIN_TRY { - ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - } H5E_END_TRY; + /* Select unlimited hyperslab for third reference */ + start[0] = 1; + start[1] = 8; + stride[0] = 4; + stride[1] = 1; + count[0] = H5S_UNLIMITED; + count[1] = 1; + block[0] = 2; + block[1] = 2; + ret = H5Sselect_hyperslab(sid2, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - if(libver_high < H5F_LIBVER_V110) - VERIFY(ret, FAIL, "H5Dwrite"); - else - CHECK(ret, FAIL, "H5Dwrite"); + hssize_ret = H5Sget_select_npoints(sid2); + VERIFY(hssize_ret, (hssize_t)H5S_UNLIMITED, "H5Sget_select_npoints"); - /* - * Store a dataset region reference which will not get written to disk - */ + /* Store third dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[2]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Create the dataspace of the region references */ - space_NA = H5Screate_simple(1, dims_NA, NULL); - CHECK(space_NA, H5I_INVALID_HID, "H5Screate_simple"); + ret = H5Rget_obj_type3(&wbuf[2], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Create the dataset and write the region references to it */ - dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, - H5P_DEFAULT, H5P_DEFAULT); - CHECK(dset_NA, H5I_INVALID_HID, "H5Dcreate"); + /* Store fourth dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid2, H5P_DEFAULT, &wbuf[3]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Close and release resources for undefined region reference tests */ - ret = H5Dclose(dset_NA); - CHECK(ret, FAIL, "H5Dclose"); - ret = H5Sclose(space_NA); - CHECK(ret, FAIL, "H5Sclose"); + /* Write selection to disk */ + ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - /* Close disk dataspace */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* + * Store a dataset region reference which will not get written to disk + */ - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Create the dataspace of the region references */ + space_NA = H5Screate_simple(1, dims_NA, NULL); + CHECK(space_NA, H5I_INVALID_HID, "H5Screate_simple"); - /* Close uint8 dataset dataspace */ - ret = H5Sclose(sid2); - CHECK(ret, FAIL, "H5Sclose"); + /* Create the dataset and write the region references to it */ + dset_NA = H5Dcreate2(fid1, "DS_NA", H5T_STD_REF, space_NA, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + CHECK(dset_NA, H5I_INVALID_HID, "H5Dcreate"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Close and release resources for undefined region reference tests */ + ret = H5Dclose(dset_NA); + CHECK(ret, FAIL, "H5Dclose"); + ret = H5Sclose(space_NA); + CHECK(ret, FAIL, "H5Sclose"); - /* Re-open the file */ - fid1 = H5Fopen(FILE_REF_REG, H5F_ACC_RDWR, fapl); - CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* - * Start the test of an undefined reference - */ + /* Close uint8 dataset dataspace */ + ret = H5Sclose(sid2); + CHECK(ret, FAIL, "H5Sclose"); - /* Open the dataset of the undefined references */ - dset_NA = H5Dopen2(fid1, "DS_NA", H5P_DEFAULT); - CHECK(dset_NA, H5I_INVALID_HID, "H5Dopen2"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Read the data */ - ret = H5Dread(dset_NA, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_NA); - CHECK(ret, FAIL, "H5Dread"); + /* Re-open the file */ + fid1 = H5Fopen(FILE_REF_REG, H5F_ACC_RDWR, fapl); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); - /* - * Dereference an undefined reference (should fail) - */ - H5E_BEGIN_TRY { - dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); - } H5E_END_TRY; - VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); + /* + * Start the test of an undefined reference + */ - /* Close and release resources. */ - ret = H5Dclose(dset_NA); - CHECK(ret, FAIL, "H5Dclose"); + /* Open the dataset of the undefined references */ + dset_NA = H5Dopen2(fid1, "DS_NA", H5P_DEFAULT); + CHECK(dset_NA, H5I_INVALID_HID, "H5Dopen2"); - /* This close should fail since H5Ropen_object never created - * the id of the referenced object. */ - H5E_BEGIN_TRY { - ret = H5Dclose(dset2); - } H5E_END_TRY; - VERIFY(ret, FAIL, "H5Dclose"); + /* Read the data */ + ret = H5Dread(dset_NA, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata_NA); + CHECK(ret, FAIL, "H5Dread"); - /* - * End the test of an undefined reference - */ + /* + * Dereference an undefined reference (should fail) + */ + H5E_BEGIN_TRY { + dset2 = H5Ropen_object(&rdata_NA[0], H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; + VERIFY(dset2, H5I_INVALID_HID, "H5Ropen_object"); - /* Open the dataset */ - dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + /* Close and release resources. */ + ret = H5Dclose(dset_NA); + CHECK(ret, FAIL, "H5Dclose"); - /* Read selection from disk */ - H5E_BEGIN_TRY { - ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); - } H5E_END_TRY; + /* This close should fail since H5Ropen_object never created + * the id of the referenced object. */ + H5E_BEGIN_TRY { + ret = H5Dclose(dset2); + } H5E_END_TRY; + VERIFY(ret, FAIL, "H5Dclose"); - if(libver_high < H5F_LIBVER_V110) - CHECK(ret, FAIL, "H5Dread"); - else { + /* + * End the test of an undefined reference + */ + + /* Open the dataset */ + dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); + CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + + /* Read selection from disk */ + ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); CHECK(ret, FAIL, "H5Dread"); /* Try to open objects */ @@ -832,7 +838,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, 36, "H5Sget_select_npoints"); ret = (int)H5Sget_select_hyper_nblocks(sid2); VERIFY(ret, 1, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ + + /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t) * 2); + ret = H5Sget_select_hyper_blocklist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); VERIFY(coords[0], 2, "Hyperslab Coordinates"); @@ -860,7 +869,10 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) VERIFY(ret, SPACE2_DIM2, "H5Sget_select_npoints"); ret = (int)H5Sget_select_elem_npoints(sid2); VERIFY(ret, SPACE2_DIM2, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); /* allocate space for the element points */ + + /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE2_RANK * sizeof(hsize_t)); + ret = H5Sget_select_elem_pointlist(sid2, (hsize_t)0, (hsize_t)ret, coords); CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); VERIFY(coords[0], coord1[0][0], "Element Coordinates"); @@ -935,35 +947,34 @@ test_reference_region(H5F_libver_t libver_low, H5F_libver_t libver_high) } H5E_END_TRY; VERIFY(ret, FAIL, "H5Rget_obj_type3"); } /* end for */ - } - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* Close dataset access property list */ - ret = H5Pclose(dapl_id); - CHECK(ret, FAIL, "H5Pclose"); + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Destroy references */ - for(j = 0; j < SPACE1_DIM1; j++) { - ret = H5Rdestroy(&wbuf[j]); - CHECK(ret, FAIL, "H5Rdestroy"); - if(libver_high >= H5F_LIBVER_V110) { + /* Destroy references */ + for(j = 0; j < SPACE1_DIM1; j++) { + ret = H5Rdestroy(&wbuf[j]); + CHECK(ret, FAIL, "H5Rdestroy"); ret = H5Rdestroy(&rbuf[j]); CHECK(ret, FAIL, "H5Rdestroy"); } - } - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); + /* Free memory buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(dwbuf); + HDfree(drbuf); + + } } /* test_reference_region() */ /**************************************************************** @@ -1054,226 +1065,255 @@ test_reference_region_1D(H5F_libver_t libver_low, H5F_libver_t libver_high) CHECK(sid1, H5I_INVALID_HID, "H5Screate_simple"); /* Create a dataset */ - dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - CHECK(ret, FAIL, "H5Dcreate2"); + H5E_BEGIN_TRY { + dset1 = H5Dcreate2(fid1, "Dataset1", H5T_STD_REF, sid1, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + } H5E_END_TRY; - /* Create references */ + if(dset1 < 0) { - /* Select 15 2x1 hyperslabs for first reference */ - start[0] = 2; - stride[0] = 5; - count[0] = 15; - block[0] = 2; - ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); - CHECK(ret, FAIL, "H5Sselect_hyperslab"); + VERIFY(libver_high <= H5F_LIBVER_V110, TRUE, "H5Dcreate2"); - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, (block[0] * count[0]), "H5Sget_select_npoints"); + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Store first dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[0]); - CHECK(ret, FAIL, "H5Rcreate_region"); - ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); - /* Select sequence of ten points for second reference */ - coord1[0][0] = 16; - coord1[1][0] = 22; - coord1[2][0] = 38; - coord1[3][0] = 41; - coord1[4][0] = 52; - coord1[5][0] = 63; - coord1[6][0] = 70; - coord1[7][0] = 89; - coord1[8][0] = 97; - coord1[9][0] = 03; - ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); - CHECK(ret, FAIL, "H5Sselect_elements"); + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, POINT1_NPOINTS, "H5Sget_select_npoints"); + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - /* Store second dataset region */ - ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[1]); - CHECK(ret, FAIL, "H5Rcreate_region"); + } else { - /* Write selection to disk */ - ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); - CHECK(ret, FAIL, "H5Dwrite"); + CHECK(ret, FAIL, "H5Dcreate2"); - /* Close disk dataspace */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* Create references */ - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + /* Select 15 2x1 hyperslabs for first reference */ + start[0] = 2; + stride[0] = 5; + count[0] = 15; + block[0] = 2; + ret = H5Sselect_hyperslab(sid3, H5S_SELECT_SET, start, stride, count, block); + CHECK(ret, FAIL, "H5Sselect_hyperslab"); - /* Close uint8 dataset dataspace */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, (block[0] * count[0]), "H5Sget_select_npoints"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Store first dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[0]); + CHECK(ret, FAIL, "H5Rcreate_region"); + ret = H5Rget_obj_type3(&wbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Re-open the file */ - fid1 = H5Fopen(FILE_REF_REG_1D, H5F_ACC_RDWR, fapl); - CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); + /* Select sequence of ten points for second reference */ + coord1[0][0] = 16; + coord1[1][0] = 22; + coord1[2][0] = 38; + coord1[3][0] = 41; + coord1[4][0] = 52; + coord1[5][0] = 63; + coord1[6][0] = 70; + coord1[7][0] = 89; + coord1[8][0] = 97; + coord1[9][0] = 03; + ret = H5Sselect_elements(sid3, H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1); + CHECK(ret, FAIL, "H5Sselect_elements"); + + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, POINT1_NPOINTS, "H5Sget_select_npoints"); + + /* Store second dataset region */ + ret = H5Rcreate_region(fid1, "/Dataset2", sid3, H5P_DEFAULT, &wbuf[1]); + CHECK(ret, FAIL, "H5Rcreate_region"); - /* Open the dataset */ - dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); - CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); + /* Write selection to disk */ + ret = H5Dwrite(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, wbuf); + CHECK(ret, FAIL, "H5Dwrite"); - /* Read selection from disk */ - ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); - CHECK(ret, FAIL, "H5Dread"); + /* Close disk dataspace */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); - /* Try to open objects */ - dset3 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); - CHECK(dset3, H5I_INVALID_HID, "H5Ropen_object"); + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); - /* Check what H5Rget_obj_type3 function returns */ - ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); - CHECK(ret, FAIL, "H5Rget_obj_type3"); - VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); + /* Close uint8 dataset dataspace */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); - /* Check information in referenced dataset */ - sid1 = H5Dget_space(dset3); - CHECK(sid1, H5I_INVALID_HID, "H5Dget_space"); + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); - ret = (int)H5Sget_simple_extent_npoints(sid1); - VERIFY(ret, SPACE3_DIM1, "H5Sget_simple_extent_npoints"); + /* Re-open the file */ + fid1 = H5Fopen(FILE_REF_REG_1D, H5F_ACC_RDWR, fapl); + CHECK(fid1, H5I_INVALID_HID, "H5Fopen"); - /* Read from disk */ - ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); - CHECK(ret, FAIL, "H5Dread"); + /* Open the dataset */ + dset1 = H5Dopen2(fid1, "/Dataset1", H5P_DEFAULT); + CHECK(dset1, H5I_INVALID_HID, "H5Dopen2"); - for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) - VERIFY(*tu8, (uint8_t)(i * 3), "Data"); - - /* Get the hyperslab selection */ - sid3 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); - CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - - /* Verify correct hyperslab selected */ - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, 30, "H5Sget_select_npoints"); - ret = (int)H5Sget_select_hyper_nblocks(sid3); - VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); /* allocate space for the hyperslab blocks */ - ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); - CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); - VERIFY(coords[0], 2, "Hyperslab Coordinates"); - VERIFY(coords[1], 3, "Hyperslab Coordinates"); - VERIFY(coords[2], 7, "Hyperslab Coordinates"); - VERIFY(coords[3], 8, "Hyperslab Coordinates"); - VERIFY(coords[4], 12, "Hyperslab Coordinates"); - VERIFY(coords[5], 13, "Hyperslab Coordinates"); - VERIFY(coords[6], 17, "Hyperslab Coordinates"); - VERIFY(coords[7], 18, "Hyperslab Coordinates"); - VERIFY(coords[8], 22, "Hyperslab Coordinates"); - VERIFY(coords[9], 23, "Hyperslab Coordinates"); - VERIFY(coords[10], 27, "Hyperslab Coordinates"); - VERIFY(coords[11], 28, "Hyperslab Coordinates"); - VERIFY(coords[12], 32, "Hyperslab Coordinates"); - VERIFY(coords[13], 33, "Hyperslab Coordinates"); - VERIFY(coords[14], 37, "Hyperslab Coordinates"); - VERIFY(coords[15], 38, "Hyperslab Coordinates"); - VERIFY(coords[16], 42, "Hyperslab Coordinates"); - VERIFY(coords[17], 43, "Hyperslab Coordinates"); - VERIFY(coords[18], 47, "Hyperslab Coordinates"); - VERIFY(coords[19], 48, "Hyperslab Coordinates"); - VERIFY(coords[20], 52, "Hyperslab Coordinates"); - VERIFY(coords[21], 53, "Hyperslab Coordinates"); - VERIFY(coords[22], 57, "Hyperslab Coordinates"); - VERIFY(coords[23], 58, "Hyperslab Coordinates"); - VERIFY(coords[24], 62, "Hyperslab Coordinates"); - VERIFY(coords[25], 63, "Hyperslab Coordinates"); - VERIFY(coords[26], 67, "Hyperslab Coordinates"); - VERIFY(coords[27], 68, "Hyperslab Coordinates"); - VERIFY(coords[28], 72, "Hyperslab Coordinates"); - VERIFY(coords[29], 73, "Hyperslab Coordinates"); - HDfree(coords); - ret = H5Sget_select_bounds(sid3, low, high); - CHECK(ret, FAIL, "H5Sget_select_bounds"); - VERIFY(low[0], 2, "Selection Bounds"); - VERIFY(high[0], 73, "Selection Bounds"); - - /* Close region space */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + /* Read selection from disk */ + ret = H5Dread(dset1, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf); + CHECK(ret, FAIL, "H5Dread"); - /* Get the element selection */ - sid3 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); - CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - - /* Verify correct elements selected */ - ret = (int)H5Sget_select_npoints(sid3); - VERIFY(ret, 10, "H5Sget_select_npoints"); - ret = (int)H5Sget_select_elem_npoints(sid3); - VERIFY(ret, 10, "H5Sget_select_elem_npoints"); - coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); /* allocate space for the element points */ - ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); - CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); - VERIFY(coords[0], coord1[0][0], "Element Coordinates"); - VERIFY(coords[1], coord1[1][0], "Element Coordinates"); - VERIFY(coords[2], coord1[2][0], "Element Coordinates"); - VERIFY(coords[3], coord1[3][0], "Element Coordinates"); - VERIFY(coords[4], coord1[4][0], "Element Coordinates"); - VERIFY(coords[5], coord1[5][0], "Element Coordinates"); - VERIFY(coords[6], coord1[6][0], "Element Coordinates"); - VERIFY(coords[7], coord1[7][0], "Element Coordinates"); - VERIFY(coords[8], coord1[8][0], "Element Coordinates"); - VERIFY(coords[9], coord1[9][0], "Element Coordinates"); - HDfree(coords); - ret = H5Sget_select_bounds(sid3, low, high); - CHECK(ret, FAIL, "H5Sget_select_bounds"); - VERIFY(low[0], 3, "Selection Bounds"); - VERIFY(high[0], 97, "Selection Bounds"); - - /* Close region space */ - ret = H5Sclose(sid3); - CHECK(ret, FAIL, "H5Sclose"); + /* Try to open objects */ + dset3 = H5Ropen_object(&rbuf[0], H5P_DEFAULT, dapl_id); + CHECK(dset3, H5I_INVALID_HID, "H5Ropen_object"); - /* Close first space */ - ret = H5Sclose(sid1); - CHECK(ret, FAIL, "H5Sclose"); + /* Check what H5Rget_obj_type3 function returns */ + ret = H5Rget_obj_type3(&rbuf[0], H5P_DEFAULT, &obj_type); + CHECK(ret, FAIL, "H5Rget_obj_type3"); + VERIFY(obj_type, H5O_TYPE_DATASET, "H5Rget_obj_type3"); - /* Close dereferenced Dataset */ - ret = H5Dclose(dset3); - CHECK(ret, FAIL, "H5Dclose"); + /* Check information in referenced dataset */ + sid1 = H5Dget_space(dset3); + CHECK(sid1, H5I_INVALID_HID, "H5Dget_space"); - /* Close Dataset */ - ret = H5Dclose(dset1); - CHECK(ret, FAIL, "H5Dclose"); + ret = (int)H5Sget_simple_extent_npoints(sid1); + VERIFY(ret, SPACE3_DIM1, "H5Sget_simple_extent_npoints"); - /* Close dataset access property list */ - ret = H5Pclose(dapl_id); - CHECK(ret, FAIL, "H5Pclose"); + /* Read from disk */ + ret = H5Dread(dset3, H5T_STD_U8LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, drbuf); + CHECK(ret, FAIL, "H5Dread"); - /* Close file access property list */ - ret = H5Pclose(fapl); - CHECK(ret, FAIL, "H5Pclose"); + for(tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++) + VERIFY(*tu8, (uint8_t)(i * 3), "Data"); - /* Close file */ - ret = H5Fclose(fid1); - CHECK(ret, FAIL, "H5Fclose"); + /* Get the hyperslab selection */ + sid3 = H5Ropen_region(&rbuf[0], H5P_DEFAULT, H5P_DEFAULT); + CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); - /* Destroy references */ - for(i = 0; i < 2; i++) { - ret = H5Rdestroy(&wbuf[i]); - CHECK(ret, FAIL, "H5Rdestroy"); - ret = H5Rdestroy(&rbuf[i]); - CHECK(ret, FAIL, "H5Rdestroy"); - } + /* Verify correct hyperslab selected */ + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, 30, "H5Sget_select_npoints"); + ret = (int)H5Sget_select_hyper_nblocks(sid3); + VERIFY(ret, 15, "H5Sget_select_hyper_nblocks"); - /* Free memory buffers */ - HDfree(wbuf); - HDfree(rbuf); - HDfree(dwbuf); - HDfree(drbuf); + /* allocate space for the hyperslab blocks */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t) * 2); + + ret = H5Sget_select_hyper_blocklist(sid3, (hsize_t)0, (hsize_t)ret, coords); + CHECK(ret, FAIL, "H5Sget_select_hyper_blocklist"); + VERIFY(coords[0], 2, "Hyperslab Coordinates"); + VERIFY(coords[1], 3, "Hyperslab Coordinates"); + VERIFY(coords[2], 7, "Hyperslab Coordinates"); + VERIFY(coords[3], 8, "Hyperslab Coordinates"); + VERIFY(coords[4], 12, "Hyperslab Coordinates"); + VERIFY(coords[5], 13, "Hyperslab Coordinates"); + VERIFY(coords[6], 17, "Hyperslab Coordinates"); + VERIFY(coords[7], 18, "Hyperslab Coordinates"); + VERIFY(coords[8], 22, "Hyperslab Coordinates"); + VERIFY(coords[9], 23, "Hyperslab Coordinates"); + VERIFY(coords[10], 27, "Hyperslab Coordinates"); + VERIFY(coords[11], 28, "Hyperslab Coordinates"); + VERIFY(coords[12], 32, "Hyperslab Coordinates"); + VERIFY(coords[13], 33, "Hyperslab Coordinates"); + VERIFY(coords[14], 37, "Hyperslab Coordinates"); + VERIFY(coords[15], 38, "Hyperslab Coordinates"); + VERIFY(coords[16], 42, "Hyperslab Coordinates"); + VERIFY(coords[17], 43, "Hyperslab Coordinates"); + VERIFY(coords[18], 47, "Hyperslab Coordinates"); + VERIFY(coords[19], 48, "Hyperslab Coordinates"); + VERIFY(coords[20], 52, "Hyperslab Coordinates"); + VERIFY(coords[21], 53, "Hyperslab Coordinates"); + VERIFY(coords[22], 57, "Hyperslab Coordinates"); + VERIFY(coords[23], 58, "Hyperslab Coordinates"); + VERIFY(coords[24], 62, "Hyperslab Coordinates"); + VERIFY(coords[25], 63, "Hyperslab Coordinates"); + VERIFY(coords[26], 67, "Hyperslab Coordinates"); + VERIFY(coords[27], 68, "Hyperslab Coordinates"); + VERIFY(coords[28], 72, "Hyperslab Coordinates"); + VERIFY(coords[29], 73, "Hyperslab Coordinates"); + HDfree(coords); + ret = H5Sget_select_bounds(sid3, low, high); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(low[0], 2, "Selection Bounds"); + VERIFY(high[0], 73, "Selection Bounds"); + + /* Close region space */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Get the element selection */ + sid3 = H5Ropen_region(&rbuf[1], H5P_DEFAULT, H5P_DEFAULT); + CHECK(sid3, H5I_INVALID_HID, "H5Ropen_region"); + + /* Verify correct elements selected */ + ret = (int)H5Sget_select_npoints(sid3); + VERIFY(ret, 10, "H5Sget_select_npoints"); + ret = (int)H5Sget_select_elem_npoints(sid3); + VERIFY(ret, 10, "H5Sget_select_elem_npoints"); + + /* allocate space for the element points */ + coords = (hsize_t *)HDmalloc((size_t)ret * SPACE3_RANK * sizeof(hsize_t)); + + ret = H5Sget_select_elem_pointlist(sid3, (hsize_t)0, (hsize_t)ret, coords); + CHECK(ret, FAIL, "H5Sget_select_elem_pointlist"); + VERIFY(coords[0], coord1[0][0], "Element Coordinates"); + VERIFY(coords[1], coord1[1][0], "Element Coordinates"); + VERIFY(coords[2], coord1[2][0], "Element Coordinates"); + VERIFY(coords[3], coord1[3][0], "Element Coordinates"); + VERIFY(coords[4], coord1[4][0], "Element Coordinates"); + VERIFY(coords[5], coord1[5][0], "Element Coordinates"); + VERIFY(coords[6], coord1[6][0], "Element Coordinates"); + VERIFY(coords[7], coord1[7][0], "Element Coordinates"); + VERIFY(coords[8], coord1[8][0], "Element Coordinates"); + VERIFY(coords[9], coord1[9][0], "Element Coordinates"); + HDfree(coords); + ret = H5Sget_select_bounds(sid3, low, high); + CHECK(ret, FAIL, "H5Sget_select_bounds"); + VERIFY(low[0], 3, "Selection Bounds"); + VERIFY(high[0], 97, "Selection Bounds"); + + /* Close region space */ + ret = H5Sclose(sid3); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close first space */ + ret = H5Sclose(sid1); + CHECK(ret, FAIL, "H5Sclose"); + + /* Close dereferenced Dataset */ + ret = H5Dclose(dset3); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close Dataset */ + ret = H5Dclose(dset1); + CHECK(ret, FAIL, "H5Dclose"); + + /* Close dataset access property list */ + ret = H5Pclose(dapl_id); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file access property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + + /* Close file */ + ret = H5Fclose(fid1); + CHECK(ret, FAIL, "H5Fclose"); + + /* Destroy references */ + for(i = 0; i < 2; i++) { + ret = H5Rdestroy(&wbuf[i]); + CHECK(ret, FAIL, "H5Rdestroy"); + ret = H5Rdestroy(&rbuf[i]); + CHECK(ret, FAIL, "H5Rdestroy"); + } + + /* Free memory buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(dwbuf); + HDfree(drbuf); + + } } /* test_reference_region_1D() */ /**************************************************************** @@ -2828,7 +2868,7 @@ test_reference(void) for(high = H5F_LIBVER_EARLIEST; high < H5F_LIBVER_NBOUNDS; high++) { /* Invalid combinations, just continue */ - if(high <= H5F_LIBVER_V110 || high < low) + if(high == H5F_LIBVER_EARLIEST || high < low) continue; test_reference_region(low, high); /* Test basic H5R dataset region reference code */ diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt index d88e27f..a9f45d5 100644 --- a/testpar/CMakeLists.txt +++ b/testpar/CMakeLists.txt @@ -22,6 +22,7 @@ set (testphdf5_SOURCES #-- Adding test for testhdf5 add_executable (testphdf5 ${testphdf5_SOURCES}) +target_compile_options(testphdf5 PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (testphdf5 PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" ) @@ -40,6 +41,7 @@ set_target_properties (testphdf5 PROPERTIES FOLDER test/par) MACRO (ADD_H5P_EXE file) add_executable (${file} ${HDF5_TEST_PAR_SOURCE_DIR}/${file}.c) + target_compile_options(${file} PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories (${file} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" ) diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index 9ce7538..ff9ca43 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -38,6 +38,7 @@ 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 +58,7 @@ 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/CMakeLists.txt b/tools/libtest/CMakeLists.txt index 7246e66..3e0f671 100644 --- a/tools/libtest/CMakeLists.txt +++ b/tools/libtest/CMakeLists.txt @@ -5,6 +5,7 @@ project (HDF5_TOOLS_LIBTEST C) # Add the h5tools_utils test executables #----------------------------------------------------------------------------- add_executable (h5tools_test_utils ${HDF5_TOOLS_LIBTEST_SOURCE_DIR}/h5tools_test_utils.c) +target_compile_options(h5tools_test_utils PRIVATE "${HDF5_CMAKE_C_FLAGS}") target_include_directories(h5tools_test_utils PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5tools_test_utils STATIC) diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 726f4c4..8956bb5 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -16,6 +16,7 @@ * Jacob Smith 2017-11-10 */ +#include "h5tools.h" #include "h5tools_utils.h" #include "h5test.h" @@ -960,7 +961,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 +1148,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 +1171,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..4087ab4 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}) @@ -40,6 +42,7 @@ if (H5_HAVE_PARALLEL) ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c ) target_include_directories (ph5diff PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (ph5diff STATIC) target_link_libraries (ph5diff PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") set_target_properties (ph5diff PROPERTIES FOLDER tools) @@ -52,6 +55,7 @@ if (H5_HAVE_PARALLEL) ${HDF5_TOOLS_SRC_H5DIFF_SOURCE_DIR}/ph5diff_main.c ) target_include_directories (ph5diff-shared PRIVATE "${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") + target_compile_options(ph5diff-shared PRIVATE "${HDF5_CMAKE_C_FLAGS}") TARGET_C_PROPERTIES (ph5diff-shared SHARED) target_link_libraries (ph5diff-shared PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") set_target_properties (ph5diff-shared PROPERTIES FOLDER tools) 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 |