From 8f103a935be942a4240da9e57a0f67504588948a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 26 Sep 2018 16:04:34 -0500 Subject: HDFFV-10594, 10332, 10531 --- CMakeLists.txt | 3 + config/cmake_ext_mod/HDFMacros.cmake | 15 + java/test/TestH5E.java | 18 +- java/test/TestH5Edefault.java | 43 +- release_docs/RELEASE.txt | 28 +- src/CMakeLists.txt | 99 ++- src/H5detect.c | 961 ++++++++++++-------------- src/H5make_libsettings.c | 252 ++++--- test/CMakeLists.txt | 2 +- test/CMakeTests.cmake | 66 +- tools/src/h5dump/h5dump.c | 2 +- tools/src/h5format_convert/h5format_convert.c | 164 ++--- tools/src/h5jam/h5jam.c | 30 +- tools/src/misc/h5debug.c | 2 +- tools/test/h5copy/CMakeTests.cmake | 3 +- tools/test/h5dump/CMakeTests.cmake | 3 +- tools/test/h5dump/CMakeTestsXML.cmake | 3 +- tools/test/h5import/CMakeTests.cmake | 3 +- tools/test/h5repack/CMakeTests.cmake | 24 +- 19 files changed, 879 insertions(+), 842 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a0a039..24bb83d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,9 @@ endif () # dependencies of the HDF5 libs may be 'incomplete', add additional # dependencies to this variable so that external projects pick them up # +#option (HDF5_EXTERNAL_LIB_PREFIX "Use prefix for custom library naming." "") +set (HDF5_EXTERNAL_LIB_PREFIX "" CACHE STRING "Use prefix for custom library naming.") +mark_as_advanced (HDF5_EXTERNAL_LIB_PREFIX) # HDF5_EXTERNAL_LIB_PREFIX : # If the parent project needs to install hdf libraries, but avoid # name conflicts with system versions, then a prefix may be added diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake index aa18022..147ae2f 100644 --- a/config/cmake_ext_mod/HDFMacros.cmake +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -358,6 +358,21 @@ macro (HDF_DIR_PATHS package_prefix) endif () endif () + set (CMAKE_SKIP_BUILD_RPATH FALSE) + set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) + set (CMAKE_BUILD_WITH_INSTALL_RPATH ON) + if (APPLE) + set (CMAKE_INSTALL_NAME_DIR "@rpath") + set (CMAKE_INSTALL_RPATH + "@executable_path/../${${package_prefix}_INSTALL_LIB_DIR}" + "@executable_path/" + "@loader_path/../${${package_prefix}_INSTALL_LIB_DIR}" + "@loader_path/" + ) + else () + set (CMAKE_INSTALL_RPATH "\$ORIGIN/../${${package_prefix}_INSTALL_LIB_DIR}:\$ORIGIN/") + endif () + if (DEFINED ADDITIONAL_CMAKE_PREFIX_PATH AND EXISTS "${ADDITIONAL_CMAKE_PREFIX_PATH}") set (CMAKE_PREFIX_PATH ${ADDITIONAL_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH}) endif () diff --git a/java/test/TestH5E.java b/java/test/TestH5E.java index 656069a..59ff50e 100644 --- a/java/test/TestH5E.java +++ b/java/test/TestH5E.java @@ -37,6 +37,10 @@ import org.junit.rules.TestName; public class TestH5E { @Rule public TestName testname = new TestName(); + + public static final int ERRSTACK_CNT = 4; + public static final int ERRSTACK_MTY_CNT = 0; + long hdf_java_classid = -1; long current_stackid = -1; @@ -158,7 +162,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Epop #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT); try { num_msg = H5.H5Eget_num(current_stackid); @@ -168,7 +172,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Epop #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT); try { H5.H5Epop(current_stackid, 1); @@ -186,7 +190,7 @@ public class TestH5E { fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop", num_msg == 3); + assertTrue("H5.H5Epop", num_msg == TestH5E.ERRSTACK_CNT - 1); } @Test @@ -227,7 +231,7 @@ public class TestH5E { try { num_msg = H5.H5Eget_num(estack_id); - assertTrue("testH5Epush #:" + num_msg, num_msg == 0); + assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT); } catch (Throwable err) { err.printStackTrace(); @@ -238,7 +242,7 @@ public class TestH5E { try { num_msg = H5.H5Eget_num(estack_id); - assertTrue("testH5Epush #:" + num_msg, num_msg == 1); + assertTrue("testH5Epush #:" + num_msg, num_msg == TestH5E.ERRSTACK_MTY_CNT + 1); } catch (Throwable err) { err.printStackTrace(); @@ -314,7 +318,7 @@ public class TestH5E { err.printStackTrace(); fail("testH5Ewalk:H5Eget_num " + err); } - assertTrue("testH5Ewalk #:" + num_msg, num_msg == 4); + assertTrue("testH5Ewalk #:" + num_msg, num_msg == TestH5E.ERRSTACK_CNT); try { H5.H5Ewalk2(current_stackid, HDF5Constants.H5E_WALK_UPWARD, walk_cb, walk_data); @@ -324,7 +328,7 @@ public class TestH5E { fail("testH5Ewalk:H5Ewalk2 " + err); } assertFalse("testH5Ewalk:H5Ewalk2 ",((H5E_walk_data)walk_data).walkdata.isEmpty()); - assertTrue("testH5Ewalk:H5Ewalk2 "+((H5E_walk_data)walk_data).walkdata.size(),((H5E_walk_data)walk_data).walkdata.size()==4); + assertTrue("testH5Ewalk:H5Ewalk2 "+((H5E_walk_data)walk_data).walkdata.size(),((H5E_walk_data)walk_data).walkdata.size()==TestH5E.ERRSTACK_CNT); } } diff --git a/java/test/TestH5Edefault.java b/java/test/TestH5Edefault.java index 5324d3a..a3057c6 100644 --- a/java/test/TestH5Edefault.java +++ b/java/test/TestH5Edefault.java @@ -29,6 +29,9 @@ import org.junit.rules.TestName; public class TestH5Edefault { @Rule public TestName testname = new TestName(); + public static final int ERRSTACK_CNT = 4; + public static final int ERRSTACK_MTY_CNT = 0; + @Before public void H5Eset_default_stack() { assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); @@ -91,7 +94,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack and clears the current stack try { @@ -122,7 +125,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eclose_stack(stack_id); @@ -153,7 +156,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack and clears the current stack try { @@ -174,7 +177,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 0); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_MTY_CNT); //Verify the copy has the correct number of messages try { @@ -184,7 +187,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Generate errors on default stack try { @@ -202,7 +205,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT); //Remove one message from the current stack try { @@ -213,7 +216,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == 3); + assertTrue("H5.H5Eget_current_stack: pop #:" + num_msg_default, num_msg_default == TestH5Edefault.ERRSTACK_CNT - 1); //Verify the copy still has the correct number of messages try { @@ -223,7 +226,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eget_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); } @Test(expected = IllegalArgumentException.class) @@ -293,7 +296,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Save a copy of the current stack try { @@ -314,7 +317,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Generate errors on default stack try { @@ -332,7 +335,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); //Remove one message from the current stack try { @@ -343,7 +346,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == 3); + assertTrue("H5.H5Eset_current_stack: pop #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1); //Verify the copy still has the correct number of messages try { @@ -353,7 +356,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eset_current_stack(stack_id); @@ -363,7 +366,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eset_current_stack: " + err); } - assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == 4); + assertTrue("H5.H5Eset_current_stack: get_num - " + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); } @Test(expected = IllegalArgumentException.class) @@ -386,7 +389,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop before #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Epop before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Epop(HDF5Constants.H5E_DEFAULT, 1); num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT); @@ -395,7 +398,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Epop: " + err); } - assertTrue("H5.H5Epop after #:" + num_msg, num_msg == 3); + assertTrue("H5.H5Epop after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT - 1); } @Test(expected = IllegalArgumentException.class) @@ -471,7 +474,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eclear2_with_msg: " + err); } - assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == 4); + assertTrue("H5.H5Eclear2_with_msg before #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_CNT); try { H5.H5Eclear2(HDF5Constants.H5E_DEFAULT); num_msg = H5.H5Eget_num(HDF5Constants.H5E_DEFAULT); @@ -480,7 +483,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eclear2_with_msg: " + err); } - assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Eclear2_with_msg after #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT); } @Test(expected = IllegalArgumentException.class) @@ -516,7 +519,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_num: " + err); } - assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == 0); + assertTrue("H5.H5Eget_num #:" + num_msg, num_msg == TestH5Edefault.ERRSTACK_MTY_CNT); } @Test @@ -534,7 +537,7 @@ public class TestH5Edefault { err.printStackTrace(); fail("H5.H5Eget_num_with_msg: " + err); } - assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > 0); + assertTrue("H5.H5Eget_num_with_msg #:" + num_msg, num_msg > TestH5Edefault.ERRSTACK_MTY_CNT); } } diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 609202c..7ba578a 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -47,11 +47,26 @@ New Features Configuration: ------------- - - + - Add default rpath to targets + + Default rpaths should be set in shared executables and + libraries to allow the use of loading dependent libraries + without requiring LD_LIBRARY_PATH to be set. The default + path should be relative using @rpath on osx and $ORIGIN + on linux. Windows is not affected. + + (ADB - 2018/09/26, HDFFV-10594) + Library: -------- - - + - Allow pre-generated H5Tinit.c and H5make_libsettings.c to be used. + + Rather than always running H5detect and generating H5Tinit.c and + H5make_libsettings.c, supply a location for those files. + + (ADB - 2018/09/18, HDFFV-10332) + Parallel Library: ----------------- @@ -98,6 +113,15 @@ Bug Fixes since HDF5-1.10.3 release Library ------- + - Allow H5detect and H5make_libsettings to take a file as an argument. + + Rather than only writing to stdout, add a command argument to name + the file that H5detect and H5make_libsettings will use for output. + Without an argument, stdout is still used, so backwards compatibility + is maintained. + + (ADB - 2018/09/05, HDFFV-9059) + - A bug was discovered in the parallel library where an application would hang if a collective read/write of a chunked dataset occurred when collective metadata reads were enabled and some of the ranks diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3c5526f..d16adf8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -853,24 +853,62 @@ endif () # Setup the H5detect utility which generates H5Tinit with platform # specific type checks inside #----------------------------------------------------------------------------- -add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) -target_include_directories(H5detect PRIVATE "${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") -target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) -TARGET_C_PROPERTIES (H5detect STATIC) -target_link_libraries (H5detect - PRIVATE "$<$:${MPI_C_LIBRARIES}>" $<$:ws2_32.lib> - INTERFACE $<$:"-O0"> -) +option (HDF5_USE_PREGEN "Use pre-generated Files" OFF) +if (HDF5_USE_PREGEN) + set (HDF5_GENERATED_SOURCE_DIR ${HDF5_USE_PREGEN_DIR}) +else () + set (HDF5_GENERATED_SOURCE_DIR ${HDF5_BINARY_DIR}) +endif () -add_custom_command ( - OUTPUT ${HDF5_BINARY_DIR}/H5Tinit.c - COMMAND $ - ARGS > ${HDF5_BINARY_DIR}/H5Tinit.c - DEPENDS H5detect -) +if (BUILD_SHARED_LIBS) + file (MAKE_DIRECTORY "${HDF5_BINARY_DIR}/shared") +endif () + +if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) + add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c) + target_include_directories(H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) + TARGET_C_PROPERTIES (H5detect STATIC) + target_link_libraries (H5detect + PRIVATE "$<$:${MPI_C_LIBRARIES}>" $<$:ws2_32.lib> + INTERFACE $<$:"-O0"> + ) + + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + COMMAND $ + ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + DEPENDS H5detect + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + ) + if (BUILD_SHARED_LIBS) + if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c) + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + COMMAND $ + ARGS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + DEPENDS H5detect + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}/shared + ) + else () + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) + endif () + endif () +else () + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) + if (BUILD_SHARED_LIBS) + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ) + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) + endif () +endif () add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) -target_include_directories(H5make_libsettings PRIVATE "${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") +target_include_directories(H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS}) TARGET_C_PROPERTIES (H5make_libsettings STATIC) target_link_libraries (H5make_libsettings @@ -881,10 +919,19 @@ target_link_libraries (H5make_libsettings add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c COMMAND $ - ARGS > ${HDF5_BINARY_DIR}/H5lib_settings.c + ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c DEPENDS H5make_libsettings WORKING_DIRECTORY ${HDF5_BINARY_DIR} ) +if (BUILD_SHARED_LIBS) + add_custom_command ( + OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c + COMMAND $ + ARGS ${HDF5_BINARY_DIR}/shared/H5lib_settings.c + DEPENDS H5make_libsettings + WORKING_DIRECTORY ${HDF5_BINARY_DIR} + ) +endif () ## all_packages="AC,B,B2,D,F,FA,FL,FS,HL,I,O,S,ST,T,Z" #all_packages="AC,B2,CX,D,F,HL,I,O,S,ST,T,Z" @@ -893,7 +940,7 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF) #----------------------------------------------------------------------------- # Add H5Tinit source to build - generated by H5detect/CMake at configure time #----------------------------------------------------------------------------- -set (gen_SRCS ${HDF5_BINARY_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) +set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) target_include_directories(${HDF5_LIB_TARGET} @@ -921,22 +968,8 @@ set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries) set (install_targets ${HDF5_LIB_TARGET}) if (BUILD_SHARED_LIBS) - file (MAKE_DIRECTORY "${HDF5_BINARY_DIR}/shared") - add_custom_command ( - OUTPUT ${HDF5_BINARY_DIR}/shared/H5Tinit.c - COMMAND $ - ARGS > ${HDF5_BINARY_DIR}/shared/H5Tinit.c - DEPENDS H5detect - WORKING_DIRECTORY ${HDF5_BINARY_DIR}/shared - ) - add_custom_command ( - OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c - COMMAND $ - ARGS > ${HDF5_BINARY_DIR}/shared/H5lib_settings.c - DEPENDS H5make_libsettings - WORKING_DIRECTORY ${HDF5_BINARY_DIR} - ) - set (shared_gen_SRCS ${HDF5_BINARY_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) + set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) + add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) target_include_directories(${HDF5_LIBSH_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" diff --git a/src/H5detect.c b/src/H5detect.c index 2d33a3d..4424009 100644 --- a/src/H5detect.c +++ b/src/H5detect.c @@ -26,11 +26,6 @@ static const char *FileHeader = "\n\ * help@hdfgroup.org. *\n\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; /* - * - * Created: H5detect.c - * 10 Aug 1997 - * Robb Matzke - * * Purpose: This code was borrowed heavily from the `detect.c' * program in the AIO distribution from Lawrence * Livermore National Laboratory. @@ -44,9 +39,6 @@ static const char *FileHeader = "\n\ * features which aren't available. We're not * running on a Vax or other machine with mixed * endianness. - * - * Modifications: - * *------------------------------------------------------------------------- */ #undef NDEBUG @@ -117,6 +109,8 @@ typedef struct malign_t { unsigned int comp_align; /* alignment for structure */ } malign_t; +FILE *rawoutstream = NULL; + /* global variables types detection code */ H5_GCC_DIAG_OFF(larger-than=) static detected_t d_g[MAXDETECT]; @@ -143,9 +137,9 @@ static void detect_C99_integers32(void); static void detect_C99_integers64(void); static void detect_alignments(void); static unsigned int align_g[] = {1, 2, 4, 8, 16}; -static int align_status_g = 0; /* ALIGNMENT Signal Status */ +static int align_status_g = 0; /* ALIGNMENT Signal Status */ static int sigbus_handler_called_g = 0; /* how many times called */ -static int sigsegv_handler_called_g = 0;/* how many times called */ +static int sigsegv_handler_called_g = 0; /* how many times called */ static int sigill_handler_called_g = 0; /* how many times called */ static int signal_handler_tested_g = 0; /* how many times tested */ #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) @@ -156,18 +150,13 @@ static H5JMP_BUF jbuf_g; #endif + /*------------------------------------------------------------------------- * Function: precision * - * Purpose: Determine the precision and offset. - * - * Return: void - * - * Programmer: Robb Matzke - * Thursday, June 18, 1998 - * - * Modifications: + * Purpose: Determine the precision and offset. * + * Return: void *------------------------------------------------------------------------- */ static void @@ -175,21 +164,22 @@ precision (detected_t *d) { unsigned int n; - if (0 == d->msize) { + if(0 == d->msize) { /* * An integer. The permutation can have negative values at the * beginning or end which represent padding of bytes. We must adjust * the precision and offset accordingly. */ - if (d->perm[0] < 0) { + if(d->perm[0] < 0) { /* * Lower addresses are padded. */ - for (n = 0; n < d->size && d->perm[n] < 0; n++) + for(n = 0; n < d->size && d->perm[n] < 0; n++) /*void*/; d->precision = 8 * (d->size - n); d->offset = 0; - } else if (d->perm[d->size - 1] < 0) { + } + else if(d->perm[d->size - 1] < 0) { /* * Higher addresses are padded. */ @@ -197,36 +187,34 @@ precision (detected_t *d) /*void*/; d->precision = 8 * (d->size - n); d->offset = 8 * n; - } else { + } + else { /* * No padding. */ d->precision = 8 * d->size; d->offset = 0; } - } else { + } + else { /* A floating point */ d->offset = MIN3(d->mpos, d->epos, d->sign); d->precision = d->msize + d->esize + 1; } } - + /*------------------------------------------------------------------------- * Function: DETECT_I/DETECT_BYTE * - * Purpose: These macro takes a type like `int' and a base name like - * `nati' and detects the byte order. The VAR is used to - * construct the names of the C variables defined. + * Purpose: These macro takes a type like `int' and a base name like + * `nati' and detects the byte order. The VAR is used to + * construct the names of the C variables defined. * * DETECT_I is used for types that are larger than one byte, * DETECT_BYTE is used for types that are exactly one byte. * - * Return: void - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 12 1996 + * Return: void * * Modifications: * @@ -244,7 +232,7 @@ precision (detected_t *d) * * Neil Fortner, 6 Sep 2013 * Split macro into DETECT_I and DETECT_BYTE macros, extracted - * common cod einto DETECT_I_BYTE_CORE. This was done to remove + * common code into DETECT_I_BYTE_CORE. This was done to remove * "will never be executed" warnings. * *------------------------------------------------------------------------- @@ -289,22 +277,15 @@ precision (detected_t *d) DETECT_I_BYTE_CORE(TYPE,VAR,INFO,TYPE) \ } - + /*------------------------------------------------------------------------- * Function: DETECT_F * - * Purpose: This macro takes a floating point type like `double' and - * a base name like `natd' and detects byte order, mantissa - * location, exponent location, sign bit location, presence or - * absence of implicit mantissa bit, and exponent bias and - * initializes a detected_t structure with those properties. - * - * Return: void - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 12 1996 - * + * Purpose: This macro takes a floating point type like `double' and + * a base name like `natd' and detects byte order, mantissa + * location, exponent location, sign bit location, presence or + * absence of implicit mantissa bit, and exponent bias and + * initializes a detected_t structure with those properties. *------------------------------------------------------------------------- */ #define DETECT_F(TYPE,VAR,INFO) { \ @@ -393,22 +374,15 @@ precision (detected_t *d) } \ } - + /*------------------------------------------------------------------------- * Function: DETECT_M * - * Purpose: This macro takes only miscellaneous structures or pointer + * Purpose: This macro takes only miscellaneous structures or pointer * (pointer, hvl_t, hobj_ref_t, hdset_reg_ref_t). It - * constructs the names and decides the alignment in structure. - * - * Return: void - * - * Programmer: Raymond Lu - * slu@ncsa.uiuc.edu - * Dec 9, 2002 - * - * Modifications: + * constructs the names and decides the alignment in structure. * + * Return: void *------------------------------------------------------------------------- */ #define DETECT_M(TYPE,VAR,INFO) { \ @@ -438,29 +412,29 @@ precision (detected_t *d) _buf = (char*)HDmalloc(sizeof(TYPE) + align_g[NELMTS(align_g) - 1]); \ if(H5SETJMP(jbuf_g)) _ano++; \ if(_ano < NELMTS(align_g)) { \ - *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\ - /* Cray Check: This section helps detect alignment on Cray's */ \ + *((TYPE*)(_buf+align_g[_ano])) = _val; /*possible SIGBUS or SEGSEGV*/ \ + _val2 = *((TYPE*)(_buf+align_g[_ano])); /*possible SIGBUS or SEGSEGV*/\ + /* Cray Check: This section helps detect alignment on Cray's */ \ /* vector machines (like the SV1) which mask off */ \ - /* pointer values when pointing to non-word aligned */ \ - /* locations with pointers that are supposed to be */ \ - /* word aligned. -QAK */ \ - HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ - /*How to handle VAX types?*/ \ - if(INFO.perm[0]) /* Big-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ - else /* Little-Endian */ \ - HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ - _val2 = *((TYPE*)(_buf+align_g[_ano])); \ - H5_GCC_DIAG_OFF(float-equal) \ - if(_val!=_val2) \ - H5LONGJMP(jbuf_g, 1); \ - H5_GCC_DIAG_ON(float-equal) \ - /* End Cray Check */ \ - (INFO.align)=align_g[_ano]; \ + /* pointer values when pointing to non-word aligned */ \ + /* locations with pointers that are supposed to be */ \ + /* word aligned. -QAK */ \ + HDmemset(_buf, 0xff, sizeof(TYPE)+align_g[NELMTS(align_g)-1]); \ + /*How to handle VAX types?*/ \ + if(INFO.perm[0]) /* Big-Endian */ \ + HDmemcpy(_buf+align_g[_ano]+(INFO.size-((INFO.offset+INFO.precision)/8)),((char *)&_val)+(INFO.size-((INFO.offset+INFO.precision)/8)),(size_t)(INFO.precision/8)); \ + else /* Little-Endian */ \ + HDmemcpy(_buf+align_g[_ano]+(INFO.offset/8),((char *)&_val)+(INFO.offset/8),(size_t)(INFO.precision/8)); \ + _val2 = *((TYPE*)(_buf+align_g[_ano])); \ + H5_GCC_DIAG_OFF(float-equal) \ + if(_val!=_val2) \ + H5LONGJMP(jbuf_g, 1); \ + H5_GCC_DIAG_ON(float-equal) \ + /* End Cray Check */ \ + (INFO.align)=align_g[_ano]; \ } else { \ (INFO.align)=0; \ - fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ + fprintf(stderr, "unable to calculate alignment for %s\n", #TYPE); \ } \ HDfree(_buf); \ HDsignal(SIGBUS, _handler); /*restore original handler*/ \ @@ -476,21 +450,16 @@ precision (detected_t *d) #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) + /*------------------------------------------------------------------------- * Function: sigsegv_handler * - * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction() - * because it's more portable to non-Posix systems. Although - * it's not nearly as nice to work with, it does the job for - * this simple stuff. - * - * Return: Returns via H5LONGJMP to jbuf_g. - * - * Programmer: Robb Matzke - * Thursday, March 18, 1999 - * - * Modifications: + * Purpose: Handler for SIGSEGV. We use signal() instead of sigaction() + * because it's more portable to non-Posix systems. Although + * it's not nearly as nice to work with, it does the job for + * this simple stuff. * + * Return: Returns via H5LONGJMP to jbuf_g. *------------------------------------------------------------------------- */ static void @@ -514,21 +483,16 @@ sigsegv_handler(int H5_ATTR_UNUSED signo) #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) + /*------------------------------------------------------------------------- * Function: sigbus_handler * - * Purpose: Handler for SIGBUS. We use signal() instead of sigaction() - * because it's more portable to non-Posix systems. Although - * it's not nearly as nice to work with, it does the job for - * this simple stuff. - * - * Return: Returns via H5LONGJMP to jbuf_g. - * - * Programmer: Robb Matzke - * Thursday, March 18, 1999 - * - * Modifications: + * Purpose: Handler for SIGBUS. We use signal() instead of sigaction() + * because it's more portable to non-Posix systems. Although + * it's not nearly as nice to work with, it does the job for + * this simple stuff. * + * Return: Returns via H5LONGJMP to jbuf_g. *------------------------------------------------------------------------- */ static void @@ -552,19 +516,16 @@ sigbus_handler(int H5_ATTR_UNUSED signo) #if defined(H5LONGJMP) && defined(H5_HAVE_SIGNAL) + /*------------------------------------------------------------------------- * Function: sigill_handler * - * Purpose: Handler for SIGILL. We use signal() instead of sigaction() - * because it's more portable to non-Posix systems. Although - * it's not nearly as nice to work with, it does the job for - * this simple stuff. - * - * Return: Returns via H5LONGJMP to jbuf_g. - * - * Programmer: Raymond Lu - * 28 October 2013 + * Purpose: Handler for SIGILL. We use signal() instead of sigaction() + * because it's more portable to non-Posix systems. Although + * it's not nearly as nice to work with, it does the job for + * this simple stuff. * + * Return: Returns via H5LONGJMP to jbuf_g. *------------------------------------------------------------------------- */ static void @@ -586,20 +547,13 @@ sigill_handler(int H5_ATTR_UNUSED signo) } #endif - + /*------------------------------------------------------------------------- * Function: print_results * - * Purpose: Prints information about the detected data types. - * - * Return: void - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 14, 1996 - * - * Modifications: + * Purpose: Prints information about the detected data types. * + * Return: void *------------------------------------------------------------------------- */ static void @@ -609,7 +563,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) int i, j; /* Include files */ - printf("\ + fprintf(rawoutstream, "\ /****************/\n\ /* Module Setup */\n\ /****************/\n\ @@ -662,7 +616,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /*********************/\n\ \n\ \n"); - printf("\n\ + fprintf(rawoutstream, "\n\ /*******************/\n\ /* Local Variables */\n\ /*******************/\n\ @@ -670,7 +624,7 @@ print_results(int nd, detected_t *d, int na, malign_t *misc_align) /* The interface initialization function */ - printf("\n\ + fprintf(rawoutstream, "\n\ \n\ /*-------------------------------------------------------------------------\n\ * Function: H5T__init_native\n\ @@ -713,12 +667,12 @@ H5T__init_native(void)\n\ } /* Print a comment to describe this section of definitions. */ - printf("\n /*\n"); + fprintf(rawoutstream, "\n /*\n"); iprint(d+i); - printf(" */\n"); + fprintf(rawoutstream, " */\n"); /* The part common to fixed and floating types */ - printf("\ + fprintf(rawoutstream, "\ if(NULL == (dt = H5T__alloc()))\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, \"datatype allocation failed\")\n\ dt->shared->state = H5T_STATE_IMMUTABLE;\n\ @@ -728,16 +682,16 @@ H5T__init_native(void)\n\ d[i].size); /*size */ if(byte_order==-1) - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_VAX;\n"); else if(byte_order==0) - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_LE;\n"); else - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.order = H5T_ORDER_BE;\n"); - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.offset = %d;\n\ dt->shared->u.atomic.prec = %d;\n\ dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\ @@ -746,14 +700,15 @@ H5T__init_native(void)\n\ d[i].precision); /*precision */ /*HDassert((d[i].perm[0]>0)==(byte_order>0));*/ /* Double-check that byte-order doesn't change */ - if (0 == d[i].msize) { + if(0 == d[i].msize) { /* The part unique to fixed point types */ - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.i.sign = H5T_SGN_%s;\n", d[i].sign ? "2" : "NONE"); - } else { + } + else { /* The part unique to floating point types */ - printf("\ + fprintf(rawoutstream, "\ dt->shared->u.atomic.u.f.sign = %d;\n\ dt->shared->u.atomic.u.f.epos = %d;\n\ dt->shared->u.atomic.u.f.esize = %d;\n\ @@ -772,11 +727,11 @@ H5T__init_native(void)\n\ } /* Atomize the type */ - printf("\ + fprintf(rawoutstream, "\ if((H5T_NATIVE_%s_g = H5I_register(H5I_DATATYPE, dt, FALSE)) < 0)\n\ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \"can't register ID for built-in datatype\")\n", d[i].varname); - printf(" H5T_NATIVE_%s_ALIGN_g = %lu;\n", + fprintf(rawoutstream, " H5T_NATIVE_%s_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].align)); /* Variables for alignment of compound datatype */ @@ -784,28 +739,29 @@ H5T__init_native(void)\n\ !HDstrcmp(d[i].varname, "INT") || !HDstrcmp(d[i].varname, "LONG") || !HDstrcmp(d[i].varname, "LLONG") || !HDstrcmp(d[i].varname, "FLOAT") || !HDstrcmp(d[i].varname, "DOUBLE") || !HDstrcmp(d[i].varname, "LDOUBLE")) { - printf(" H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", + fprintf(rawoutstream, " H5T_NATIVE_%s_COMP_ALIGN_g = %lu;\n", d[i].varname, (unsigned long)(d[i].comp_align)); } } /* Consider VAX a little-endian machine */ if(byte_order==0 || byte_order==-1) { - printf("\n\ + fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ H5T_native_order_g = H5T_ORDER_%s;\n", "LE"); - } else { - printf("\n\ + } + else { + fprintf(rawoutstream, "\n\ /* Set the native order for this machine */\n\ H5T_native_order_g = H5T_ORDER_%s;\n", "BE"); } /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */ - printf("\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n"); + fprintf(rawoutstream, "\n /* Structure alignment for pointers, hvl_t, hobj_ref_t, hdset_reg_ref_t */\n"); for(j=0; jsize - 1) / 4; ; --pass) { + for(pass = (d->size - 1) / 4; ; --pass) { unsigned int i, k; /* * Print the byte ordering above the bit fields. */ - printf(" * "); - for (i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { - printf("%4d", d->perm[i]); - if (i > pass * 4) HDfputs(" ", stdout); - if (!i) break; + fprintf(rawoutstream, " * "); + for(i = MIN(pass * 4 + 3, d->size - 1); i >= pass * 4; --i) { + fprintf(rawoutstream, "%4d", d->perm[i]); + if(i > pass * 4) + HDfputs(" ", stdout); + if(!i) + break; } /* * Print the bit fields */ - printf("\n * "); - for (i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, + fprintf(rawoutstream, "\n * "); + for(i = MIN(pass * 4 + 3, d->size - 1), k = MIN(pass * 32 + 31, 8 * d->size - 1); i >= pass * 4; --i) { unsigned int j; - for (j = 8; j > 0; --j) { - if (k == d->sign && d->msize) { - HDputchar('S'); - } else if (k >= d->epos && k < d->epos + d->esize) { - HDputchar('E'); - } else if (k >= d->mpos && k < d->mpos + d->msize) { - HDputchar('M'); - } else if (d->msize) { - HDputchar('?'); /*unknown floating point bit */ - } else if (d->sign) { - HDputchar('I'); - } else { - HDputchar('U'); + for(j = 8; j > 0; --j) { + if(k == d->sign && d->msize) { + HDfputc('S', rawoutstream); + } + else if(k >= d->epos && k < d->epos + d->esize) { + HDfputc('E', rawoutstream); + } + else if(k >= d->mpos && k < d->mpos + d->msize) { + HDfputc('M', rawoutstream); + } + else if(d->msize) { + HDfputc('?', rawoutstream); /*unknown floating point bit */ + } + else if(d->sign) { + HDfputc('I', rawoutstream); + } + else { + HDfputc('U', rawoutstream); } --k; } - if (i > pass * 4) HDputchar(' '); - if (!i) break; + if(i > pass * 4) + HDfputc(' ', rawoutstream); + if(!i) + break; } - HDputchar('\n'); - if (!pass) break; + HDfputc('\n', rawoutstream); + if(!pass) + break; } /* * Is there an implicit bit in the mantissa. */ - if (d->msize) { - printf(" * Implicit bit? %s\n", d->imp ? "yes" : "no"); + if(d->msize) { + fprintf(rawoutstream, " * Implicit bit? %s\n", d->imp ? "yes" : "no"); } /* * Alignment */ - if (0 == d->align) { - printf(" * Alignment: NOT CALCULATED\n"); - } else if (1 == d->align) { - printf(" * Alignment: none\n"); - } else { - printf(" * Alignment: %lu\n", (unsigned long) (d->align)); + if(0 == d->align) { + fprintf(rawoutstream, " * Alignment: NOT CALCULATED\n"); + } + else if(1 == d->align) { + fprintf(rawoutstream, " * Alignment: none\n"); + } + else { + fprintf(rawoutstream, " * Alignment: %lu\n", (unsigned long) (d->align)); } } - + /*------------------------------------------------------------------------- * Function: byte_cmp * - * Purpose: Compares two chunks of memory A and B and returns the - * byte index into those arrays of the first byte that - * differs between A and B. Ignores differences where the + * Purpose: Compares two chunks of memory A and B and returns the + * byte index into those arrays of the first byte that + * differs between A and B. Ignores differences where the * corresponding bit in pad_mask is set to 0. * - * Return: Success: Index of differing byte. - * - * Failure: -1 if all bytes are the same. - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 12, 1996 - * - * Modifications: - * + * Return: Success: Index of differing byte. + * Failure: -1 if all bytes are the same. *------------------------------------------------------------------------- */ static int @@ -990,17 +943,17 @@ byte_cmp(int n, const void *_a, const void *_b, const unsigned char *pad_mask) return -1; } - + /*------------------------------------------------------------------------- * Function: bit_cmp * - * Purpose: Compares two bit vectors and returns the index for the - * first bit that differs between the two vectors. The - * size of the vector is NBYTES. PERM is a mapping from - * actual order to little endian. Ignores differences where + * Purpose: Compares two bit vectors and returns the index for the + * first bit that differs between the two vectors. The + * size of the vector is NBYTES. PERM is a mapping from + * actual order to little endian. Ignores differences where * the corresponding bit in pad_mask is set to 0. * - * Return: Index of first differing bit. + * Return: Index of first differing bit. * *------------------------------------------------------------------------- */ @@ -1013,14 +966,14 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, unsigned char *b = (unsigned char *) _b; unsigned char aa, bb; - for (i = 0; i < nbytes; i++) { + for(i = 0; i < nbytes; i++) { HDassert(perm[i] < (int) nbytes); - if ((aa = (unsigned char) (a[perm[i]] & pad_mask[perm[i]])) + if((aa = (unsigned char) (a[perm[i]] & pad_mask[perm[i]])) != (bb = (unsigned char) (b[perm[i]] & pad_mask[perm[i]]))) { unsigned int j; - for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { - if ((aa & 1) != (bb & 1)) return i * 8 + j; + for(j = 0; j < 8; j++, aa >>= 1, bb >>= 1) { + if((aa & 1) != (bb & 1)) return i * 8 + j; } fprintf(stderr, "INTERNAL ERROR"); HDabort(); @@ -1031,26 +984,19 @@ bit_cmp(unsigned int nbytes, int *perm, void *_a, void *_b, return 0; } - + /*------------------------------------------------------------------------- * Function: fix_order * - * Purpose: Given an array PERM with elements FIRST through LAST - * initialized with zero origin byte numbers, this function - * creates a permutation vector that maps the actual order - * of a floating point number to little-endian. - * - * This function assumes that the mantissa byte ordering - * implies the total ordering. - * - * Return: void + * Purpose: Given an array PERM with elements FIRST through LAST + * initialized with zero origin byte numbers, this function + * creates a permutation vector that maps the actual order + * of a floating point number to little-endian. * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 13, 1996 - * - * Modifications: + * This function assumes that the mantissa byte ordering + * implies the total ordering. * + * Return: void *------------------------------------------------------------------------- */ static void @@ -1058,79 +1004,79 @@ fix_order(int n, int last, int *perm, const char **mesg) { int i; - if (last > 1) { - /* - * We have at least three points to consider. - */ - if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { + if(last > 1) { /* - * Little endian. - */ - if (mesg) *mesg = "Little-endian"; - for (i = 0; i < n; i++) perm[i] = i; + * We have at least three points to consider. + */ + if(perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { + /* + * Little endian. + */ + if(mesg) + *mesg = "Little-endian"; + for(i = 0; i < n; i++) + perm[i] = i; - } else if (perm[last] > perm[last-1] && perm[last-1] > perm[last-2]) { - /* - * Big endian. - */ - if (mesg) *mesg = "Big-endian"; - for (i = 0; i < n; i++) perm[i] = (n - 1) - i; + } + else if(perm[last] > perm[last - 1] + && perm[last - 1] > perm[last - 2]) { + /* + * Big endian. + */ + if(mesg) + *mesg = "Big-endian"; + for(i = 0; i < n; i++) + perm[i] = (n - 1) - i; - } else { - /* - * Bi-endian machines like VAX. + } + else { + /* + * Bi-endian machines like VAX. * (NOTE: This is not an actual determination of the VAX-endianness. * It could have some other endianness and fall into this * case - JKM & QAK) - */ - HDassert(0 == n % 2); - if (mesg) *mesg = "VAX"; - for (i = 0; i < n; i += 2) { - perm[i] = (n - 2) - i; - perm[i + 1] = (n - 1) - i; + */ + HDassert(0 == n % 2); + if(mesg) + *mesg = "VAX"; + for(i = 0; i < n; i += 2) { + perm[i] = (n - 2) - i; + perm[i + 1] = (n - 1) - i; + } } } - } else { - fprintf(stderr, - "Failed to detect byte order of %d-byte floating point.\n", n); - HDexit(1); + else { + fprintf(stderr, + "Failed to detect byte order of %d-byte floating point.\n", n); + HDexit(1); } } - + /*------------------------------------------------------------------------- * Function: imp_bit * - * Purpose: Looks for an implicit bit in the mantissa. The value - * of _A should be 1.0 and the value of _B should be 0.5. - * Some floating-point formats discard the most significant - * bit of the mantissa after normalizing since it will always - * be a one (except for 0.0). If this is true for the native - * floating point values stored in _A and _B then the function - * returns non-zero. + * Purpose: Looks for an implicit bit in the mantissa. The value + * of _A should be 1.0 and the value of _B should be 0.5. + * Some floating-point formats discard the most significant + * bit of the mantissa after normalizing since it will always + * be a one (except for 0.0). If this is true for the native + * floating point values stored in _A and _B then the function + * returns non-zero. * - * This function assumes that the exponent occupies higher - * order bits than the mantissa and that the most significant - * bit of the mantissa is next to the least significant bit - * of the exponent. + * This function assumes that the exponent occupies higher + * order bits than the mantissa and that the most significant + * bit of the mantissa is next to the least significant bit + * of the exponent. * * - * Return: Success: Non-zero if the most significant bit - * of the mantissa is discarded (ie, the - * mantissa has an implicit `one' as the - * most significant bit). Otherwise, - * returns zero. + * Return: Success: Non-zero if the most significant bit + * of the mantissa is discarded (ie, the + * mantissa has an implicit `one' as the + * most significant bit). Otherwise, + * returns zero. * - * Failure: exit(1) - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 13, 1996 - * - * Modifications: - * - * Robb Matzke, 6 Nov 1996 - * Fixed a bug that occurs with non-implicit architectures. + * Failure: 1 * *------------------------------------------------------------------------- */ @@ -1160,26 +1106,14 @@ imp_bit(unsigned int n, int *perm, void *_a, void *_b, const unsigned char *pad_ return (a[perm[major]] >> minor) & 0x01 ? 0 : 1; } - + /*------------------------------------------------------------------------- - * Function: find_bias - * - * Purpose: Determines the bias of the exponent. This function should - * be called with _A having a value of `1'. + * Function: find_bias * - * Return: Success: The exponent bias. + * Purpose: Determines the bias of the exponent. This function should + * be called with _A having a value of `1'. * - * Failure: - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 13, 1996 - * - * Modifications: - * - * Robb Matzke, 6 Nov 1996 - * Fixed a bug with non-implicit architectures returning the - * wrong exponent bias. + * Return: The exponent bias. * *------------------------------------------------------------------------- */ @@ -1190,7 +1124,7 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) unsigned char mask; unsigned int b, shift = 0, nbits, bias = 0; - while (esize > 0) { + while(esize > 0) { nbits = MIN(esize, (8 - epos % 8)); mask = (unsigned char) ((1 << nbits) - 1); b = (unsigned int) (a[perm[epos / 8]] >> (epos % 8)) & mask; @@ -1203,34 +1137,27 @@ find_bias(unsigned int epos, unsigned int esize, int *perm, void *_a) return bias; } - + /*------------------------------------------------------------------------- * Function: print_header * - * Purpose: Prints the C file header for the generated file. - * - * Return: void - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Mar 12 1997 - * - * Modifications: + * Purpose: Prints the C file header for the generated file. * + * Return: void *------------------------------------------------------------------------- */ static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); - char real_name[30]; - char host_name[256]; + time_t now = HDtime(NULL); + struct tm *tm = HDlocaltime(&now); + char real_name[30]; + char host_name[256]; int i; - const char *s; + const char *s; #ifdef H5_HAVE_GETPWUID - struct passwd *pwd = NULL; + struct passwd *pwd = NULL; #else int pwd = 1; #endif @@ -1281,20 +1208,21 @@ bit.\n"; */ #ifdef H5_HAVE_GETPWUID { - size_t n; - char *comma; - if ((pwd = HDgetpwuid(HDgetuid()))) { - if ((comma = HDstrchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); - HDstrncpy(real_name, pwd->pw_gecos, n); - real_name[n] = '\0'; - } else { - HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); - real_name[sizeof(real_name) - 1] = '\0'; + size_t n; + char *comma; + if((pwd = HDgetpwuid(HDgetuid()))) { + if((comma = HDstrchr(pwd->pw_gecos, ','))) { + n = MIN(sizeof(real_name)-1, (unsigned)(comma-pwd->pw_gecos)); + HDstrncpy(real_name, pwd->pw_gecos, n); + real_name[n] = '\0'; + } + else { + HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + real_name[sizeof(real_name) - 1] = '\0'; + } } - } else { - real_name[0] = '\0'; - } + else + real_name[0] = '\0'; } #else real_name[0] = '\0'; @@ -1304,8 +1232,8 @@ bit.\n"; * The FQDM of this host or the empty string. */ #ifdef H5_HAVE_GETHOSTNAME - if (HDgethostname(host_name, sizeof(host_name)) < 0) { - host_name[0] = '\0'; + if(HDgethostname(host_name, sizeof(host_name)) < 0) { + host_name[0] = '\0'; } #else host_name[0] = '\0'; @@ -1314,78 +1242,71 @@ bit.\n"; /* * The file header: warning, copyright notice, build information. */ - printf("/* Generated automatically by H5detect -- do not edit */\n\n\n"); - HDputs(FileHeader); /*the copyright notice--see top of this file */ + fprintf(rawoutstream, "/* Generated automatically by H5detect -- do not edit */\n\n\n"); + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - printf(" *\n * Created:\t\t%s %2d, %4d\n", + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); - if (pwd || real_name[0] || host_name[0]) { - printf(" *\t\t\t"); - if (real_name[0]) printf("%s <", real_name); + if(pwd || real_name[0] || host_name[0]) { + fprintf(rawoutstream, " *\t\t\t"); + if(real_name[0]) + fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if (pwd) HDfputs(pwd->pw_name, stdout); + if(pwd) HDfputs(pwd->pw_name, rawoutstream); #endif - if (host_name[0]) printf("@%s", host_name); - if (real_name[0]) printf(">"); - HDputchar('\n'); + if(host_name[0]) + fprintf(rawoutstream, "@%s", host_name); + if(real_name[0]) + fprintf(rawoutstream, ">"); + HDfputc('\n', rawoutstream); } - printf(" *\n * Purpose:\t\t"); - for (s = purpose; *s; s++) { - HDputchar(*s); - if ('\n' == *s && s[1]) printf(" *\t\t\t"); + fprintf(rawoutstream, " *\n * Purpose:\t\t"); + for(s = purpose; *s; s++) { + HDfputc(*s, rawoutstream); + if('\n' == *s && s[1]) + fprintf(rawoutstream, " *\t\t\t"); } - printf(" *\n * Modifications:\n *\n"); - printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); - printf(" *\tIt was generated by code in `H5detect.c'.\n"); + fprintf(rawoutstream, " *\n * Modifications:\n *\n"); + fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); + fprintf(rawoutstream, " *\tIt was generated by code in `H5detect.c'.\n"); - printf(" *\n *"); - for (i = 0; i < 73; i++) HDputchar('-'); - printf("\n */\n\n"); + fprintf(rawoutstream, " *\n *"); + for(i = 0; i < 73; i++) + HDfputc('-', rawoutstream); + fprintf(rawoutstream, "\n */\n\n"); } - + /*------------------------------------------------------------------------- * Function: detect_C89_integers * - * Purpose: Detect C89 integer types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C89 integer types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN detect_C89_integers(void) { - DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++; - DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++; - DETECT_I(short, SHORT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++; - DETECT_I(int, INT, d_g[nd_g]); nd_g++; - DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++; - DETECT_I(long, LONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++; + DETECT_BYTE(signed char, SCHAR, d_g[nd_g]); nd_g++; + DETECT_BYTE(unsigned char, UCHAR, d_g[nd_g]); nd_g++; + DETECT_I(short, SHORT, d_g[nd_g]); nd_g++; + DETECT_I(unsigned short, USHORT, d_g[nd_g]); nd_g++; + DETECT_I(int, INT, d_g[nd_g]); nd_g++; + DETECT_I(unsigned int, UINT, d_g[nd_g]); nd_g++; + DETECT_I(long, LONG, d_g[nd_g]); nd_g++; + DETECT_I(unsigned long, ULONG, d_g[nd_g]); nd_g++; } - + /*------------------------------------------------------------------------- * Function: detect_C89_floats * - * Purpose: Detect C89 floating point types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C89 floating point types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1395,19 +1316,13 @@ detect_C89_floats(void) DETECT_F(double, DOUBLE, d_g[nd_g]); nd_g++; } - + /*------------------------------------------------------------------------- * Function: detect_C99_integers8 * - * Purpose: Detect C99 8 bit integer types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C99 8 bit integer types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1415,61 +1330,55 @@ detect_C99_integers8(void) { #if H5_SIZEOF_INT8_T>0 #if H5_SIZEOF_INT8_T==1 - DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++; + DETECT_BYTE(int8_t, INT8, d_g[nd_g]); nd_g++; #else - DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++; + DETECT_I(int8_t, INT8, d_g[nd_g]); nd_g++; #endif #endif #if H5_SIZEOF_UINT8_T>0 #if H5_SIZEOF_UINT8_T==1 - DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++; + DETECT_BYTE(uint8_t, UINT8, d_g[nd_g]); nd_g++; #else - DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++; + DETECT_I(uint8_t, UINT8, d_g[nd_g]); nd_g++; #endif #endif #if H5_SIZEOF_INT_LEAST8_T>0 #if H5_SIZEOF_INT_LEAST8_T==1 - DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; + DETECT_BYTE(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; #else - DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; + DETECT_I(int_least8_t, INT_LEAST8, d_g[nd_g]); nd_g++; #endif #endif #if H5_SIZEOF_UINT_LEAST8_T>0 #if H5_SIZEOF_UINT_LEAST8_T==1 - DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; + DETECT_BYTE(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; #else - DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; + DETECT_I(uint_least8_t, UINT_LEAST8, d_g[nd_g]); nd_g++; #endif #endif #if H5_SIZEOF_INT_FAST8_T>0 #if H5_SIZEOF_INT_FAST8_T==1 - DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; + DETECT_BYTE(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; #else DETECT_I(int_fast8_t, INT_FAST8, d_g[nd_g]); nd_g++; #endif #endif #if H5_SIZEOF_UINT_FAST8_T>0 #if H5_SIZEOF_UINT_FAST8_T==1 - DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; + DETECT_BYTE(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; #else - DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; + DETECT_I(uint_fast8_t, UINT_FAST8, d_g[nd_g]); nd_g++; #endif #endif } - + /*------------------------------------------------------------------------- * Function: detect_C99_integers16 * - * Purpose: Detect C99 16 bit integer types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C99 16 bit integer types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1479,35 +1388,29 @@ detect_C99_integers16(void) DETECT_I(int16_t, INT16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT16_T>0 - DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++; + DETECT_I(uint16_t, UINT16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST16_T>0 - DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++; + DETECT_I(int_least16_t, INT_LEAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST16_T>0 - DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++; + DETECT_I(uint_least16_t, UINT_LEAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST16_T>0 - DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++; + DETECT_I(int_fast16_t, INT_FAST16, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST16_T>0 - DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++; + DETECT_I(uint_fast16_t, UINT_FAST16, d_g[nd_g]); nd_g++; #endif } - + /*------------------------------------------------------------------------- * Function: detect_C99_integers32 * - * Purpose: Detect C99 32 bit integer types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C99 32 bit integer types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1517,34 +1420,29 @@ detect_C99_integers32(void) DETECT_I(int32_t, INT32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT32_T>0 - DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++; + DETECT_I(uint32_t, UINT32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST32_T>0 - DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++; + DETECT_I(int_least32_t, INT_LEAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST32_T>0 - DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++; + DETECT_I(uint_least32_t, UINT_LEAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST32_T>0 - DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++; + DETECT_I(int_fast32_t, INT_FAST32, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST32_T>0 - DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++; + DETECT_I(uint_fast32_t, UINT_FAST32, d_g[nd_g]); nd_g++; #endif } - + /*------------------------------------------------------------------------- * Function: detect_C99_integers64 * - * Purpose: Detect C99 64 bit integer types + * Purpose: Detect C99 64 bit integer types * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Return: void * *------------------------------------------------------------------------- */ @@ -1555,24 +1453,24 @@ detect_C99_integers64(void) DETECT_I(int64_t, INT64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT64_T>0 - DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++; + DETECT_I(uint64_t, UINT64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_LEAST64_T>0 - DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++; + DETECT_I(int_least64_t, INT_LEAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_LEAST64_T>0 - DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++; + DETECT_I(uint_least64_t, UINT_LEAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_INT_FAST64_T>0 - DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++; + DETECT_I(int_fast64_t, INT_FAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_UINT_FAST64_T>0 - DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++; + DETECT_I(uint_fast64_t, UINT_FAST64, d_g[nd_g]); nd_g++; #endif #if H5_SIZEOF_LONG_LONG>0 DETECT_I(long long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++; + DETECT_I(unsigned long long, ULLONG, d_g[nd_g]); nd_g++; #else /* * This architecture doesn't support an integer type larger than `long' @@ -1580,23 +1478,17 @@ detect_C99_integers64(void) * `long long' is probably equivalent to `long' here anyway. */ DETECT_I(long, LLONG, d_g[nd_g]); nd_g++; - DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++; + DETECT_I(unsigned long, ULLONG, d_g[nd_g]); nd_g++; #endif } - + /*------------------------------------------------------------------------- * Function: detect_C99_integers * - * Purpose: Detect C99 integer types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C99 integer types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1610,19 +1502,13 @@ detect_C99_integers(void) detect_C99_integers64(); } - + /*------------------------------------------------------------------------- * Function: detect_C99_floats * - * Purpose: Detect C99 floating point types - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect C99 floating point types * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1641,19 +1527,13 @@ detect_C99_floats(void) #endif } - + /*------------------------------------------------------------------------- * Function: detect_alignments * - * Purpose: Detect structure alignments - * - * Return: void - * - * Programmer: Albert Cheng - * 2004/05/20 - * - * Modifications: + * Purpose: Detect structure alignments * + * Return: void *------------------------------------------------------------------------- */ static void HDF_NO_UBSAN @@ -1685,60 +1565,54 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) #endif void (*save_handler)(int) = HDsignal(signum, handler); volatile int i, val; - int ntries=5; - volatile int nfailures=0; - volatile int nsuccesses=0; - - for (i=0;i0 || nsuccesses != ntries){ - fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. " - "Found %d failures and %d successes\n", - signum, ntries, nfailures, nsuccesses); - return(-1); - }else{ - /* all succeeded */ - return(0); + if(nfailures>0 || nsuccesses != ntries) { + fprintf(stderr, "verify_signal_handlers for signal %d did %d tries. " + "Found %d failures and %d successes\n", + signum, ntries, nfailures, nsuccesses); + return -1; + } + else { + /* all succeeded */ + return 0; } } #endif - + /*------------------------------------------------------------------------- * Function: main * - * Purpose: Main entry point. - * - * Return: Success: exit(0) + * Purpose: Main entry point. * - * Failure: exit(1) - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Jun 12, 1996 + * Return: Success: EXIT_SUCCESS * * Modifications: - * Albert Cheng, 2004/05/20 * Some compilers, e.g., Intel C v7.0, took a long time to compile * with optimization when a module routine contains many code lines. * Divide up all those types detections macros into subroutines, both @@ -1747,8 +1621,23 @@ static int verify_signal_handlers(int signum, void (*handler)(int)) *------------------------------------------------------------------------- */ int HDF_NO_UBSAN -main(void) +main(int argc, char *argv[]) { + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded */ + + if(argc > 1) + fname = argv[1]; + + /* First check if filename is string "NULL" */ + if(fname != NULL) { + /* binary output */ + if((f = HDfopen(fname, "w")) != NULL) + rawoutstream = f; + } + if(!rawoutstream) + rawoutstream = stdout; #if defined(H5_HAVE_SETSYSINFO) && defined(SSI_NVPAIRS) #if defined(UAC_NOPRINT) && defined(UAC_SIGBUS) @@ -1759,8 +1648,8 @@ main(void) int nvpairs[2]; nvpairs[0] = SSIN_UACPROC; nvpairs[1] = UAC_NOPRINT | UAC_SIGBUS; - if (setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { - fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", + if(setsysinfo(SSI_NVPAIRS, nvpairs, 1, 0, 0)<0) { + fprintf(stderr, "H5detect: unable to turn off UAC handling: %s\n", HDstrerror(errno)); } #endif @@ -1768,15 +1657,15 @@ main(void) #if defined(H5SETJMP) && defined(H5_HAVE_SIGNAL) /* verify the SIGBUS and SIGSEGV handlers work properly */ - if (verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { + if(verify_signal_handlers(SIGBUS, sigbus_handler) != 0) { fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigbus_handler", SIGBUS); } - if (verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { + if(verify_signal_handlers(SIGSEGV, sigsegv_handler) != 0) { fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigsegv_handler", SIGSEGV); } - if (verify_signal_handlers(SIGILL, sigill_handler) != 0) { + if(verify_signal_handlers(SIGILL, sigill_handler) != 0) { fprintf(stderr, "Signal handler %s for signal %d failed\n", "sigill_handler", SIGILL); } @@ -1803,5 +1692,13 @@ main(void) print_results (nd_g, d_g, na_g, m_g); - return 0; + if(rawoutstream && rawoutstream != stdout) { + if(HDfclose(rawoutstream)) + fprintf(stderr, "closing rawoutstream"); + else + rawoutstream = NULL; + } + + return EXIT_SUCCESS; } + diff --git a/src/H5make_libsettings.c b/src/H5make_libsettings.c index 1892806..da7c8d9 100644 --- a/src/H5make_libsettings.c +++ b/src/H5make_libsettings.c @@ -26,13 +26,8 @@ static const char *FileHeader = "\n\ * help@hdfgroup.org. *\n\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"; /* - * - * Created: H5make_libsettings.c - * 17 Mar 2010 - * Quincey Koziol - * - * Purpose: Generate the H5libsettings.c file from the - * libhdf5.settings file. + * Purpose: Generate the H5libsettings.c file from the + * libhdf5.settings file. * *------------------------------------------------------------------------- */ @@ -43,33 +38,31 @@ static const char *FileHeader = "\n\ #define LIBSETTINGSFNAME "libhdf5.settings" +FILE *rawoutstream = NULL; + /*------------------------------------------------------------------------- - * Function: insert_libhdf5_settings - * - * Purpose: insert the contents of libhdf5.settings into a file - * represented by flibinfo. - * Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not - * defined, i.e., not enabled. + * Function: insert_libhdf5_settings * - * Return: void - * - * Programmer: Albert Cheng - * Apr 20, 2009 + * Purpose: insert the contents of libhdf5.settings into a file + * represented by flibinfo. + * Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not + * defined, i.e., not enabled. * + * Return: void *------------------------------------------------------------------------- */ static void insert_libhdf5_settings(FILE *flibinfo) { #ifdef H5_HAVE_EMBEDDED_LIBINFO - FILE *fsettings; /* for files libhdf5.settings */ + FILE *fsettings; /* for files libhdf5.settings */ int inchar; - int bol = 0; /* indicates the beginning of a new line */ + int bol = 0; /* indicates the beginning of a new line */ if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) { HDperror(LIBSETTINGSFNAME); - HDexit(1); + HDexit(EXIT_FAILURE); } /* end if */ /* print variable definition and the string */ @@ -77,33 +70,33 @@ insert_libhdf5_settings(FILE *flibinfo) fprintf(flibinfo, "char H5libhdf5_settings[]=\n"); bol++; while(EOF != (inchar = HDgetc(fsettings))) { - if(bol) { - /* Start a new line */ - fprintf(flibinfo, "\t\""); - bol = 0; - } /* end if */ - if(inchar == '\n') { - /* end of a line */ - fprintf(flibinfo, "\\n\"\n"); - bol++; + if(bol) { + /* Start a new line */ + fprintf(flibinfo, "\t\""); + bol = 0; + } /* end if */ + if(inchar == '\n') { + /* end of a line */ + fprintf(flibinfo, "\\n\"\n"); + bol++; } /* end if */ - else - HDputc(inchar, flibinfo); + else + HDputc(inchar, flibinfo); } /* end while */ if(HDfeof(fsettings)) { - /* wrap up */ - if(!bol) - /* EOF found without a new line */ - fprintf(flibinfo, "\\n\"\n"); - fprintf(flibinfo, ";\n\n"); + /* wrap up */ + if(!bol) + /* EOF found without a new line */ + fprintf(flibinfo, "\\n\"\n"); + fprintf(flibinfo, ";\n\n"); } /* end if */ else { - fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); - HDexit(1); + fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME); + HDexit(EXIT_FAILURE); } /* end else */ if(0 != HDfclose(fsettings)) { - HDperror(LIBSETTINGSFNAME); - HDexit(1); + HDperror(LIBSETTINGSFNAME); + HDexit(EXIT_FAILURE); } /* end if */ #else /* print variable definition and an empty string */ @@ -114,59 +107,50 @@ insert_libhdf5_settings(FILE *flibinfo) /*------------------------------------------------------------------------- - * Function: make_libinfo - * - * Purpose: Create the embedded library information definition. - * This sets up for a potential extension that the declaration - * is printed to a file different from stdout. - * - * Return: void + * Function: make_libinfo * - * Programmer: Albert Cheng - * Sep 15, 2009 + * Purpose: Create the embedded library information definition. + * This sets up for a potential extension that the declaration + * is printed to a file different from stdout. * + * Return: void *------------------------------------------------------------------------- */ static void make_libinfo(void) { /* print variable definition and then the string as a macro. */ - insert_libhdf5_settings(stdout); + insert_libhdf5_settings(rawoutstream); } /*------------------------------------------------------------------------- - * Function: print_header + * Function: print_header * - * Purpose: Prints the header for the generated file. - * - * Return: void - * - * Programmer: Robb Matzke - * matzke@llnl.gov - * Mar 12 1997 + * Purpose: Prints the header for the generated file. * + * Return: void *------------------------------------------------------------------------- */ static void print_header(void) { - time_t now = HDtime(NULL); - struct tm *tm = HDlocaltime(&now); - char real_name[30]; - char host_name[256]; - int i; - const char *s; + time_t now = HDtime(NULL); + struct tm *tm = HDlocaltime(&now); + char real_name[30]; + char host_name[256]; + int i; + const char *s; #ifdef H5_HAVE_GETPWUID - struct passwd *pwd = NULL; + struct passwd *pwd = NULL; #else - int pwd = 1; + int pwd = 1; #endif - static const char *month_name[] = + static const char *month_name[] = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - static const char *purpose = "\ + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + static const char *purpose = "\ This machine-generated source code contains\n\ information about the library build configuration\n"; @@ -175,22 +159,22 @@ information about the library build configuration\n"; */ #ifdef H5_HAVE_GETPWUID { - size_t n; - char *comma; + size_t n; + char *comma; - if((pwd = HDgetpwuid(HDgetuid()))) { - if((comma = HDstrchr(pwd->pw_gecos, ','))) { - n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); - HDstrncpy(real_name, pwd->pw_gecos, n); - real_name[n] = '\0'; - } /* end if */ + if((pwd = HDgetpwuid(HDgetuid()))) { + if((comma = HDstrchr(pwd->pw_gecos, ','))) { + n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos)); + HDstrncpy(real_name, pwd->pw_gecos, n); + real_name[n] = '\0'; + } /* end if */ else { - HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); - real_name[sizeof(real_name) - 1] = '\0'; - } /* end else */ - } /* end if */ + HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name)); + real_name[sizeof(real_name) - 1] = '\0'; + } /* end else */ + } /* end if */ else - real_name[0] = '\0'; + real_name[0] = '\0'; } #else real_name[0] = '\0'; @@ -201,7 +185,7 @@ information about the library build configuration\n"; */ #ifdef H5_HAVE_GETHOSTNAME if(HDgethostname(host_name, sizeof(host_name)) < 0) - host_name[0] = '\0'; + host_name[0] = '\0'; #else host_name[0] = '\0'; #endif @@ -209,54 +193,49 @@ information about the library build configuration\n"; /* * The file header: warning, copyright notice, build information. */ - printf("/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); - HDputs(FileHeader); /*the copyright notice--see top of this file */ + fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n"); + HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */ - printf(" *\n * Created:\t\t%s %2d, %4d\n", - month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); + fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n", + month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year); if(pwd || real_name[0] || host_name[0]) { - printf(" *\t\t\t"); - if(real_name[0]) - printf("%s <", real_name); + fprintf(rawoutstream, " *\t\t\t"); + if(real_name[0]) + fprintf(rawoutstream, "%s <", real_name); #ifdef H5_HAVE_GETPWUID - if(pwd) - HDfputs(pwd->pw_name, stdout); + if(pwd) + HDfputs(pwd->pw_name, rawoutstream); #endif - if(host_name[0]) - printf("@%s", host_name); - if(real_name[0]) - printf(">"); - HDputchar('\n'); + if(host_name[0]) + fprintf(rawoutstream, "@%s", host_name); + if(real_name[0]) + fprintf(rawoutstream, ">"); + HDfputc('\n', rawoutstream); } /* end if */ - printf(" *\n * Purpose:\t\t"); + fprintf(rawoutstream, " *\n * Purpose:\t\t"); for(s = purpose; *s; s++) { - HDputchar(*s); - if('\n' == *s && s[1]) - printf(" *\t\t\t"); + HDfputc(*s, rawoutstream); + if('\n' == *s && s[1]) + fprintf(rawoutstream, " *\t\t\t"); } /* end for */ - printf(" *\n * Modifications:\n *\n"); - printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); - printf(" *\tIt was generated by code in `H5make_libsettings.c'.\n"); + fprintf(rawoutstream, " *\n * Modifications:\n *\n"); + fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n"); + fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n"); - printf(" *\n *"); + fprintf(rawoutstream, " *\n *"); for(i = 0; i < 73; i++) - HDputchar('-'); - printf("\n */\n\n"); + HDfputc('-', rawoutstream); + fprintf(rawoutstream, "\n */\n\n"); } /*------------------------------------------------------------------------- - * Function: print_footer + * Function: print_footer * - * Purpose: Prints the file footer for the generated file. - * - * Return: void - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Mar 31 2010 + * Purpose: Prints the file footer for the generated file. * + * Return: void *------------------------------------------------------------------------- */ static void @@ -267,22 +246,33 @@ print_footer(void) /*------------------------------------------------------------------------- - * Function: main - * - * Purpose: Main entry point. - * - * Return: Success: exit(0) + * Function: main * - * Failure: exit(1) - * - * Programmer: Albert Cheng - * 2010/4/1 + * Purpose: Main entry point. * + * Return: Success: EXIT_SUCCESS *------------------------------------------------------------------------- */ int -main(void) +main(int argc, char *argv[]) { + char *fname = NULL; + FILE *f; /* temporary holding place for the stream pointer + * so that rawoutstream is changed only when succeeded + */ + + if(argc > 1) + fname = argv[1]; + + /* First check if filename is string "NULL" */ + if(fname != NULL) { + /* binary output */ + if((f = HDfopen(fname, "w")) != NULL) + rawoutstream = f; + } + if(!rawoutstream) + rawoutstream = stdout; + print_header(); /* Generate embedded library information variable definition */ @@ -290,5 +280,13 @@ main(void) print_footer(); - HDexit(0); + if(rawoutstream && rawoutstream != stdout) { + if(HDfclose(rawoutstream)) + fprintf(stderr, "closing rawoutstream"); + else + rawoutstream = NULL; + } + + HDexit(EXIT_SUCCESS); } + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 517a620..c8119fe 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -224,7 +224,7 @@ set (H5_TESTS ntypes dangle dtransform - reserved + # reserved disabled cross_read freespace mf diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index cc6ebb8..8838c34 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -439,14 +439,6 @@ set (test_CLEANFILES tvlstr.h5 tvlstr2.h5 twriteorder.dat - flush.h5 - flush-swmr.h5 - noflush.h5 - noflush-swmr.h5 - flush_extend.h5 - flush_extend-swmr.h5 - noflush_extend.h5 - noflush_extend-swmr.h5 enum1.h5 titerate.h5 ttsafe.h5 @@ -551,6 +543,8 @@ set (H5TEST_SEPARATE_TESTS testhdf5 cache cache_image + flush1 + flush2 ) foreach (test ${H5_TESTS}) if (NOT ${test} IN_LIST H5TEST_SEPARATE_TESTS) @@ -587,7 +581,6 @@ foreach (test ${H5_TESTS}) endif () endforeach () -set_tests_properties (H5TEST-flush2 PROPERTIES DEPENDS H5TEST-flush1) set_tests_properties (H5TEST-fheap PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-big PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-btree2 PROPERTIES TIMEOUT 1800) @@ -630,7 +623,6 @@ if (BUILD_SHARED_LIBS) endif () endforeach () - set_tests_properties (H5TEST-shared-flush2 PROPERTIES DEPENDS H5TEST-shared-flush1) set_tests_properties (H5TEST-shared-fheap PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-shared-big PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-shared-btree2 PROPERTIES TIMEOUT 1800) @@ -720,6 +712,54 @@ if (BUILD_SHARED_LIBS) endif () endif () +#-- Adding test for flush1/2 +add_test (NAME H5TEST-clear-flush-objects + COMMAND ${CMAKE_COMMAND} + -E remove + flush.h5 + flush-swmr.h5 + noflush.h5 + noflush-swmr.h5 + flush_extend.h5 + flush_extend-swmr.h5 + noflush_extend.h5 + noflush_extend-swmr.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST +) +if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5TEST-flush1 COMMAND $) +else () + add_test (NAME H5TEST-flush1 COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=flush1.txt" + -D "TEST_FOLDER=${HDF5_TEST_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) +endif () +set_tests_properties (H5TEST-flush1 PROPERTIES + DEPENDS H5TEST-clear-flush-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST +) +if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5TEST-flush2 COMMAND $) +else () + add_test (NAME H5TEST-flush2 COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_SKIP_COMPARE=TRUE" + -D "TEST_OUTPUT=flush2.txt" + -D "TEST_FOLDER=${HDF5_TEST_BINARY_DIR}/H5TEST" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) +endif () +set_tests_properties (H5TEST-flush2 PROPERTIES DEPENDS H5TEST-flush1) + #-- Adding test for tcheck_version add_test (NAME H5TEST-tcheck_version-major COMMAND $ "-tM") set_tests_properties (H5TEST-tcheck_version-major PROPERTIES @@ -826,9 +866,10 @@ add_test (NAME H5TEST-clear-error_test-objects set_tests_properties (H5TEST-clear-error_test-objects PROPERTIES FIXTURES_SETUP error_test_clear_objects) if (HDF5_USE_16_API_DEFAULT) add_test ( - NAME H5TEST-error_test-SKIPPED + NAME H5TEST-error_test COMMAND ${CMAKE_COMMAND} -E echo "SKIP $" ) + set_property(TEST H5TEST-error_test PROPERTY DISABLED) else () add_test (NAME H5TEST-error_test COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" @@ -925,9 +966,10 @@ if (BUILD_SHARED_LIBS) set_tests_properties (H5TEST-shared-clear-error_test-objects PROPERTIES FIXTURES_SETUP shared_error_test_clear_objects) if (HDF5_USE_16_API_DEFAULT) add_test ( - NAME H5TEST-shared-error_test-SKIPPED + NAME H5TEST-shared-error_test COMMAND ${CMAKE_COMMAND} -E echo "SKIP $" ) + set_property(TEST H5TEST-shared-error_test PROPERTY DISABLED) else () add_test (NAME H5TEST-shared-error_test COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c index a5f0369..b9e37e8 100644 --- a/tools/src/h5dump/h5dump.c +++ b/tools/src/h5dump/h5dump.c @@ -65,7 +65,7 @@ struct handler_t { * parameters. The long-named ones can be partially spelled. When * adding more, make sure that they don't clash with each other. */ -/* The following initialization makes use of C language cancatenating */ +/* The following initialization makes use of C language concatenating */ /* "xxx" "yyy" into "xxxyyy". */ static const char *s_opts = "hn*peyBHirVa:c:d:f:g:k:l:t:w:xD:uX:o*b*F:s:S:A*q:z:m:RE*CM:O*N:vG:"; static struct long_options l_opts[] = { diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 0fc0289..b9ed9ce 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -226,81 +226,84 @@ convert(hid_t fid, const char *dname) /* Open the dataset */ if((did = H5Dopen2(fid, dname, H5P_DEFAULT)) < 0) { - error_msg("unable to open dataset \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; - - } else if(verbose_g) - HDfprintf(stdout, "Open the dataset\n"); + error_msg("unable to open dataset \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + else if(verbose_g) + HDfprintf(stdout, "Open the dataset\n"); /* Get the dataset's creation property list */ if((dcpl = H5Dget_create_plist(did)) < 0) { - error_msg("unable to get the dataset creation property list\n"); - h5tools_setstatus(EXIT_FAILURE); - goto error; + error_msg("unable to get the dataset creation property list\n"); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* Get the dataset's layout */ if((layout_type = H5Pget_layout(dcpl)) < 0) { - error_msg("unable to get the dataset layout type\n"); - h5tools_setstatus(EXIT_FAILURE); - goto error; - - } else if(verbose_g) - HDfprintf(stdout, "Retrieve the dataset's layout\n"); + error_msg("unable to get the dataset layout type\n"); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + else if(verbose_g) + HDfprintf(stdout, "Retrieve the dataset's layout\n"); switch(layout_type) { - case H5D_CHUNKED: - if(verbose_g) - HDfprintf(stdout, "Dataset is a chunked dataset\n"); - - /* Get the dataset's chunk indexing type */ - if(H5Dget_chunk_index_type(did, &idx_type) < 0) { - error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; - } else if(verbose_g) - HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n"); + case H5D_CHUNKED: + if(verbose_g) + HDfprintf(stdout, "Dataset is a chunked dataset\n"); + + /* Get the dataset's chunk indexing type */ + if(H5Dget_chunk_index_type(did, &idx_type) < 0) { + error_msg("unable to get the chunk indexing type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + else if(verbose_g) + HDfprintf(stdout, "Retrieve the dataset's chunk indexing type\n"); + + if(idx_type == H5D_CHUNK_IDX_BTREE) { + if(verbose_g) + HDfprintf(stdout, "Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); + h5tools_setstatus(EXIT_SUCCESS); + goto done; + } + else if (verbose_g) + HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n"); - if(idx_type == H5D_CHUNK_IDX_BTREE) { - if(verbose_g) - HDfprintf(stdout, "Dataset's chunk indexing type is already version 1 B-tree: no further action\n"); - h5tools_setstatus(EXIT_SUCCESS); - goto done; - } else if (verbose_g) - HDfprintf(stdout, "Dataset's chunk indexing type is not version 1 B-tree\n"); break; - case H5D_CONTIGUOUS: - if(verbose_g) - HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n"); - break; + case H5D_CONTIGUOUS: + if(verbose_g) + HDfprintf(stdout, "Dataset is a contiguous dataset: downgrade layout version as needed\n"); + break; - case H5D_COMPACT: - if(verbose_g) - HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n"); - break; + case H5D_COMPACT: + if(verbose_g) + HDfprintf(stdout, "Dataset is a compact dataset: downgrade layout version as needed\n"); + break; - case H5D_VIRTUAL: - if(verbose_g) - HDfprintf(stdout, "No further action for virtual dataset\n"); - goto done; + case H5D_VIRTUAL: + if(verbose_g) + HDfprintf(stdout, "No further action for virtual dataset\n"); + goto done; - case H5D_NLAYOUTS: - case H5D_LAYOUT_ERROR: - default: - error_msg("unknown layout type for \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; + case H5D_NLAYOUTS: + case H5D_LAYOUT_ERROR: + default: + error_msg("unknown layout type for \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; } /* end switch */ /* No further action if it is a noop */ if(noop_g) { - if(verbose_g) - HDfprintf(stdout, "Not converting the dataset\n"); - h5tools_setstatus(EXIT_SUCCESS); - goto done; + if(verbose_g) + HDfprintf(stdout, "Not converting the dataset\n"); + h5tools_setstatus(EXIT_SUCCESS); + goto done; } if(verbose_g) @@ -308,51 +311,54 @@ convert(hid_t fid, const char *dname) /* Downgrade the dataset */ if(H5Dformat_convert(did) < 0) { - error_msg("unable to downgrade dataset \"%s\"\n", dname); - h5tools_setstatus(EXIT_FAILURE); - goto error; - } else if(verbose_g) - HDfprintf(stdout, "Done\n"); + error_msg("unable to downgrade dataset \"%s\"\n", dname); + h5tools_setstatus(EXIT_FAILURE); + goto error; + } + else if(verbose_g) + HDfprintf(stdout, "Done\n"); done: /* Close the dataset */ if(H5Dclose(did) < 0) { error_msg("unable to close dataset \"%s\"\n", dname); h5tools_setstatus(EXIT_FAILURE); - goto error; - } else if(verbose_g) - HDfprintf(stdout, "Close the dataset\n"); + goto error; + } + else if(verbose_g) + HDfprintf(stdout, "Close the dataset\n"); /* Close the dataset creation property list */ if(H5Pclose(dcpl) < 0) { error_msg("unable to close dataset creation property list\n"); h5tools_setstatus(EXIT_FAILURE); - goto error; - } else if(verbose_g) - printf("Close the dataset creation property list\n"); + goto error; + } + else if(verbose_g) + HDprintf("Close the dataset creation property list\n"); - return(0); + return 0; error: if(verbose_g) - HDfprintf(stdout, "Error encountered\n"); + HDfprintf(stdout, "Error encountered\n"); H5E_BEGIN_TRY { H5Pclose(dcpl); H5Dclose(did); } H5E_END_TRY; - return(-1); + return -1; } /* convert() */ /*------------------------------------------------------------------------- - * Function: convert_dsets_cb() + * Function: convert_dsets_cb() * - * Purpose: The callback routine from the traversal to convert the - * chunk indexing type of the dataset object. + * Purpose: The callback routine from the traversal to convert the + * chunk indexing type of the dataset object. * - * Return: Success: 0 - * Failure: 1 + * Return: Success: 0 + * Failure: -1 *------------------------------------------------------------------------- */ static int @@ -363,11 +369,11 @@ convert_dsets_cb(const char *path, const H5O_info_t *oi, const char *already_vis /* If the object has already been seen then just return */ if(NULL == already_visited) { if(oi->type == H5O_TYPE_DATASET) { - if(verbose_g) - HDfprintf(stdout, "Going to process dataset:%s...\n", path); - if(convert(fid, path) < 0) - goto error; - } /* end if */ + if(verbose_g) + HDfprintf(stdout, "Going to process dataset:%s...\n", path); + if(convert(fid, path) < 0) + goto error; + } /* end if */ } /* end if */ return 0; diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index 01ba4af..4f3e7a4 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -221,7 +221,7 @@ main (int argc, const char *argv[]) /* Initialize h5tools lib */ h5tools_init(); - parse_command_line (argc, argv); + parse_command_line(argc, argv); if (ub_file == NULL) { /* no user block */ @@ -252,21 +252,21 @@ main (int argc, const char *argv[]) leave (EXIT_FAILURE); } - ifile = H5Fopen (input_file, H5F_ACC_RDONLY, H5P_DEFAULT); + ifile = H5Fopen(input_file, H5F_ACC_RDONLY, H5P_DEFAULT); if (ifile < 0) { error_msg("Can't open input HDF5 file \"%s\"\n", input_file); leave (EXIT_FAILURE); } - plist = H5Fget_create_plist (ifile); + plist = H5Fget_create_plist(ifile); if (plist < 0) { error_msg("Can't get file creation plist for file \"%s\"\n", input_file); H5Fclose(ifile); leave (EXIT_FAILURE); } - status = H5Pget_userblock (plist, &usize); + status = H5Pget_userblock(plist, &usize); if (status < 0) { error_msg("Can't get user block for file \"%s\"\n", input_file); H5Pclose(plist); @@ -330,7 +330,7 @@ main (int argc, const char *argv[]) } } - newubsize = compute_user_block_size ((hsize_t) fsize); + newubsize = compute_user_block_size((hsize_t) fsize); startub = usize; @@ -345,22 +345,22 @@ main (int argc, const char *argv[]) else { /* add new ub to current ublock, pad to new offset */ newubsize += usize; - newubsize = compute_user_block_size ((hsize_t) newubsize); + newubsize = compute_user_block_size((hsize_t) newubsize); } } /* copy the HDF5 from starting at usize to starting at newubsize: * makes room at 'from' for new ub */ /* if no current ub, usize is 0 */ - copy_some_to_file (h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); + copy_some_to_file(h5fid, ofid, usize, newubsize, (ssize_t) (h5fsize - usize)); /* copy the old ub to the beginning of the new file */ if (!do_clobber) { - where = copy_some_to_file (h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); + where = copy_some_to_file(h5fid, ofid, (hsize_t) 0, (hsize_t) 0, (ssize_t) usize); } /* copy the new ub to the end of the ub */ - where = copy_some_to_file (ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); + where = copy_some_to_file(ufid, ofid, (hsize_t) 0, startub, (ssize_t) - 1); /* pad the ub */ if(write_pad(ofid, where, &where) < 0) { @@ -372,18 +372,18 @@ main (int argc, const char *argv[]) } /* end if */ if(ub_file) - HDfree (ub_file); + HDfree(ub_file); if(input_file) - HDfree (input_file); + HDfree(input_file); if(output_file) - HDfree (output_file); + HDfree(output_file); if(ufid >= 0) - HDclose (ufid); + HDclose(ufid); if(h5fid >= 0) - HDclose (h5fid); + HDclose(h5fid); if(ofid >= 0) - HDclose (ofid); + HDclose(ofid); return h5tools_getstatus(); } diff --git a/tools/src/misc/h5debug.c b/tools/src/misc/h5debug.c index b66e7ce..088e6e9 100644 --- a/tools/src/misc/h5debug.c +++ b/tools/src/misc/h5debug.c @@ -346,7 +346,7 @@ main(int argc, char *argv[]) /* * Debug a global heap collection. */ - status = H5HG_debug (f, addr, stdout, 0, VCOL); + status = H5HG_debug(f, addr, stdout, 0, VCOL); } else if(!HDmemcmp(sig, H5G_NODE_MAGIC, (size_t)H5_SIZEOF_MAGIC)) { /* diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 1bdefa6..924ade1 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -128,9 +128,10 @@ macro (ADD_SKIP_H5_TEST testname skipresultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5COPY-${testname}-${skipresultfile}-SKIPPED + NAME H5COPY-${testname}-${skipresultfile} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname}-${skipresultfile} ${ARGN}" ) + set_property(TEST H5COPY-${testname}-${skipresultfile} PROPERTY DISABLED) endif () endmacro () diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index 57df850..f74ee50 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -439,9 +439,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5DUMP-${skipresultfile}-SKIPPED + NAME H5DUMP-${skipresultfile} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${skipresultfile} ${ARGN}" ) + set_property(TEST H5DUMP-${skipresultfile} PROPERTY DISABLED) endif () else () ADD_H5_TEST (${skipresultfile} ${skipresultcode} ${ARGN}) diff --git a/tools/test/h5dump/CMakeTestsXML.cmake b/tools/test/h5dump/CMakeTestsXML.cmake index 9c68e5f..de87d2f 100644 --- a/tools/test/h5dump/CMakeTestsXML.cmake +++ b/tools/test/h5dump/CMakeTestsXML.cmake @@ -164,9 +164,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5DUMP_XML-${skipresultfile}-SKIPPED + NAME H5DUMP_XML-${skipresultfile} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${skipresultfile}.xml --xml ${ARGN}" ) + set_property(TEST H5DUMP_XML-${skipresultfile} PROPERTY DISABLED) endif () else () ADD_XML_H5_TEST (${skipresultfile} ${skipresultcode} ${ARGN}) diff --git a/tools/test/h5import/CMakeTests.cmake b/tools/test/h5import/CMakeTests.cmake index 3c65b0b..7d76fba 100644 --- a/tools/test/h5import/CMakeTests.cmake +++ b/tools/test/h5import/CMakeTests.cmake @@ -283,9 +283,10 @@ macro (ADD_H5_SKIP_DUMPTEST testname datasetname testfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5IMPORT-DUMP-${testname}-SKIPPED + NAME H5IMPORT-DUMP-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${testname} ${datasetname} ${testfile} --- DEFLATE filter not available" ) + set_property(TEST H5IMPORT-DUMP-${testname} PROPERTY DISABLED) endif () endmacro () diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index f40c0b1..a063e19 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -229,9 +229,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_OLD-${testname}-SKIPPED + NAME H5REPACK_OLD-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} -i ${PROJECT_BINARY_DIR}/testfiles/${testfile} -o ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" ) + set_property(TEST H5REPACK_OLD-${testname} PROPERTY DISABLED) endif () else () add_test ( @@ -260,9 +261,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK-${testname}-SKIPPED + NAME H5REPACK-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${testfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${testfile}" ) + set_property(TEST H5REPACK-${testname} PROPERTY DISABLED) endif () else () add_test ( @@ -291,9 +293,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_CMP-${testname}-SKIPPED + NAME H5REPACK_CMP-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_CMP-${testname} PROPERTY DISABLED) endif () else () # If using memchecker add tests without using scripts @@ -338,9 +341,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_MASK-${testname}-SKIPPED + NAME H5REPACK_MASK-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_MASK-${testname} PROPERTY DISABLED) endif () else () # If using memchecker add tests without using scripts @@ -385,9 +389,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_DMP-${testname}-SKIPPED + NAME H5REPACK_DMP-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_DMP-${testname} PROPERTY DISABLED) endif () else () add_test ( @@ -427,9 +432,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_STAT-${testname}-SKIPPED + NAME H5REPACK_STAT-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${ARGN} ${PROJECT_BINARY_DIR}/testfiles/${resultfile} ${PROJECT_BINARY_DIR}/testfiles/out-${statarg}.${resultfile}" ) + set_property(TEST H5REPACK_STAT-${testname} PROPERTY DISABLED) endif () else () add_test ( @@ -469,9 +475,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_VERIFY_LAYOUT-${testname}-SKIPPED + NAME H5REPACK_VERIFY_LAYOUT-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP -d ${testdset} -pH ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_VERIFY_LAYOUT-${testname} PROPERTY DISABLED) endif () else () if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -542,9 +549,10 @@ if ("${testtype}" STREQUAL "SKIP") if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( - NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname}-SKIPPED + NAME H5REPACK_VERIFY_LAYOUT_VDS-${testname} COMMAND ${CMAKE_COMMAND} -E echo "SKIP -d ${testdset} -pH ${PROJECT_BINARY_DIR}/testfiles/out-${testname}.${resultfile}" ) + set_property(TEST H5REPACK_VERIFY_LAYOUT_VDS-${testname} PROPERTY DISABLED) endif () else () if (NOT HDF5_ENABLE_USING_MEMCHECKER) -- cgit v0.12